[Issue 11229] std.string.toLower is slow

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Mar 9 21:58:26 PST 2016


https://issues.dlang.org/show_bug.cgi?id=11229

Jon Degenhardt <jrdemail2000-dlang at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jrdemail2000-dlang at yahoo.co
                   |                            |m

--- Comment #1 from Jon Degenhardt <jrdemail2000-dlang at yahoo.com> ---
Some comments I made in this forum post:
https://forum.dlang.org/post/zyoojkmzpqizebusiild@forum.dlang.org

Routines like to toLower and asLowerCase call functions that work for all
unicode characters. I was able to create much faster versions by checking if
the character was ascii, then calling either the ascii version or the more
general version. Same is true for a few routines like isNumber. Some have the
ascii check optimization built in, but not all.

If this optimization is added, it might also be useful to add a few common
combinations (or a generic solution, if that's feasible). For example, to check
if a character is alpha-numeric, one currently ORs two tests from the standard
library, isAlpha and isNumber. Putting in an ascii optimization check requires
putting it before doing the OR, rather than inside the tests being ORed.

--


More information about the Digitalmars-d-bugs mailing list