Bug 17031 – isSortedRange uses string comparisons to check for sortedness

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-12-26T06:35:45Z
Last change time
2024-12-01T16:29:03Z
Assigned to
No Owner
Creator
Seb
Moved to GitHub: phobos#10225 →

Comments

Comment #0 by greeenify — 2016-12-26T06:35:45Z
Have a look at the way find is specialized to take advantage of sorted ranges: https://github.com/dlang/phobos/blob/master/std/algorithm/searching.d#L1377 static if (is(typeof(pred == "a == b"))) enum isDefaultPred = pred == "a == b"; else enum isDefaultPred = false; ... static if (is(InputRange : SortedRange!TT, TT) && isDefaultPred) Yep it does a string comparison and thus if the user defines a custom lambda, `find` won't take advantage of the sortedness. Moreover if another range function e.g. retro or find is applied the sortedness is not propagated. FYI: this was introduced in https://github.com/dlang/phobos/pull/4907
Comment #1 by greeenify — 2016-12-26T06:44:31Z
For propagating sortedness I created another enhancement request: https://issues.dlang.org/show_bug.cgi?id=17032
Comment #2 by robert.schadek — 2024-12-01T16:29:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10225 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB