Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 11, 2011 [phobos] phobos commit, revision 2305 | ||||
---|---|---|---|---|
| ||||
phobos commit, revision 2305 user: andrei msg: Reverted cmp and icmp to return int, take 2 http://www.dsource.org/projects/phobos/changeset/2305 paths changed: U trunk/phobos/std/string.d |
January 11, 2011 [phobos] phobos commit, revision 2305 | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsource.org | I think it would be more efficient to write it as:
static if (s1.length.sizeof == int.sizeof)
return s1.length - s2.length;
else
return s1.length > s2.length ? 1 : s1.length < s2.length ? -1 : 0;
dsource.org wrote:
> phobos commit, revision 2305
>
>
> user: andrei
>
> msg:
> Reverted cmp and icmp to return int, take 2
>
> http://www.dsource.org/projects/phobos/changeset/2305
>
> paths changed:
> U trunk/phobos/std/string.d
>
>
>
|
January 11, 2011 [phobos] phobos commit, revision 2305 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Okay, though I wonder whether that's even measurable. The bulk is the string comparison in most cases.
I think we could and probably should abstract cmp3way() in std.algorithm as a template that is specialized for various types to work as efficiently as possible.
Andrei
On 1/11/11 1:25 AM, Walter Bright wrote:
> I think it would be more efficient to write it as:
>
> static if (s1.length.sizeof == int.sizeof)
> return s1.length - s2.length;
> else
> return s1.length > s2.length ? 1 : s1.length < s2.length ? -1 : 0;
>
> dsource.org wrote:
>> phobos commit, revision 2305
>>
>>
>> user: andrei
>>
>> msg:
>> Reverted cmp and icmp to return int, take 2
>>
>> http://www.dsource.org/projects/phobos/changeset/2305
>>
>> paths changed:
>> U trunk/phobos/std/string.d
>>
>>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
January 11, 2011 [phobos] phobos commit, revision 2305 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu wrote: > Okay, though I wonder whether that's even measurable. The bulk is the string comparison in most cases. cmp is so heavily used, yes it's worth it, especially since it comes for free. > > I think we could and probably should abstract cmp3way() in std.algorithm as a template that is specialized for various types to work as efficiently as possible. > I can see at a glance what the code does, but cmp3way() I'd have to look up every time. |
Copyright © 1999-2021 by the D Language Foundation