[fpc-devel] Is calling the Windows Unicode APIs really faster than the ANSI API's?

Marco van de Voort marcov at stack.nl
Fri Sep 26 09:55:38 CEST 2008


In our previous episode, Graeme Geldenhuys said:
> Yes I know we have had lengthy discussions about this before.
> Everybody (whoever they might be) keeps saying that UTF-16 was chosen
> for Tiburon's UnicodeString because it makes "significant speed gains"
> when calling the Windows API based on UTF-16 - compared to the ANSI
> API's. The whole debate goes that you wouldn't need constant
> conversions between ANSI->UTF-16->ANSI.  Now it seems Free Pascal
> developers want to base their design on those results as well (yes,
> plus the whole compatibility thing)

Well, I discussed with Florian and Michael (and Felipe also a bit) what to
do with unicode, and I'm pretty sure speed on Windows API calls wasn't even
mentioned.
 
> Marco Cantu, as far as I can see, is the only one that shows a
> comparison and numbers. Surprisingly, the ANSI calls where faster!

Most of this is based on the old NT books from Butler c.s. where they say
all calls of NT are unicode, and the ascii ones are wrappers. However this
is aeons old, and memory constrains are less, so maybe there are two sets
now. Nobody knows.

As far as Cantu goes, be very,very careful with benchmarking:

Cantu himself says this is due to repainting. Maybe ansistrings with
CP_UTF8 the repainting is also slower. IOW it is unicode widget painting
(any encoding) vs ansi widget painting.




More information about the fpc-devel mailing list