avoid toLower in std.algorithm.sort compare alias

Steven Schveighoffer schveiguy at yahoo.com
Mon Apr 23 08:43:20 PDT 2012


On Mon, 23 Apr 2012 09:49:50 -0400, Jay Norwood <jayn at prismnet.com> wrote:

> On Monday, 23 April 2012 at 11:27:40 UTC, Steven Schveighoffer
> wrote:
>
>> I think using std.string.icmp is the best solution.  I would expect it  
>> to outperform even schwartz sort.
>>
>> -Steve
>
> icmp took longer... added about 1 sec vs  0.3 sec (for
> schwartzSort ) to the program execution time.
>
> bool myComp(string x, string y) { return std.string.icmp(x,y)<0; }
> std.algorithm.sort!(myComp)(dirs);
>
> finished! time:1396 ms

Well, that's surprising :)  Perhaps there's some room for improvement in  
icmp or std.uni.toLower.  There may be some constructs that are preventing  
inlining (enforce is the worst offender).

While dealing with unicode in my std.stream rewrite, I've found that  
hand-decoding dchars is way faster than using library calls.

-Steve


More information about the Digitalmars-d-learn mailing list