avoid toLower in std.algorithm.sort compare alias

Jay Norwood jayn at prismnet.com
Sun Apr 22 00:23:45 PDT 2012


On Sunday, 22 April 2012 at 06:26:42 UTC, Jonathan M Davis wrote:
>
> 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

ok, I did look at the code just now, and I'll sleep better
knowing that it doesn't do the whole string conversion.  I
misunderstood your pseudo-code to mean that two lower case
strings were being created prior to the compare.

However,  icmp code does appear to call the toLower conversion on
both characters without first comparing the characters for
equality, which misses the chance to do a simple compare that
would avoid the two calls.





More information about the Digitalmars-d-learn mailing list