DelphiFAQ Home Search:
General :: Programming :: Delphi :: VCL
About the Delphi VCL (Visual Component Library)

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

AnsiLowerCase() faster than LowerCase()

When I tried to speed up SourceCoder, I looked at frequent calls to AnsiLowerCase().
I had made it a habit to use AnsiLowerCase() instead of LowerCase() because I remembered that it would treat non-standard characters properly (e.g. German Umlaute => ).
The help file shows that it even handles multibyte character sets (MBCS) properly.

The plain LowerCase() does nothing of that and I assumed it might be faster.

This was not the case. The reason is that LowerCase() is implemented in Pascal (in SysUtils.pas), while AnsiLowerCase() calls a Win32 API function using #0 terminated strings.

Indeed, by changing all calls from AnsiLowerCase() to LowerCase(), SourceCoder became about 15% slower (no benchmark was needed, it was very obvious!), so I quickly changed back.

Generated 0:01:30 on Nov 18, 2018