avoid toLower in std.algorithm.sort compare alias

Jonathan M Davis jmdavisProg at gmx.com
Sat Apr 21 23:26:23 PDT 2012


On Sunday, April 22, 2012 08:20:13 Jay Norwood wrote:
> The comment below worries me a little bit about std.string.icmp.
> What if they are two 1MB strings that differ in he first
> character?  Does it really convert both strings to lower case
> before comparing the first character?
> 
> http://dlang.org/phobos/std_string.html#icmp
> 
> "Technically, icmp(r1, r2) is equivalent to
> cmp!"std.uni.toLower(a) < std.uni.toLower(b)"(r1, r2). "

You can look at the code. It checks each of the characters in place. Unlike 
toLower, it doesn't need to generate a new string. But as far as the 
comparison goes, they're the same - hence that line in the docs.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list