This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/15884] Big performance problem in strcoll


http://sourceware.org/bugzilla/show_bug.cgi?id=15884

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> ---
I agree with Ondrej. In a sense, completing early is a special case, but it's a
sufficiently common one that it should be handled without calling strlen on the
input.

A similar situation (which is handled correctly if I'm not mistaken) is
strstr("x", huge_string). Despite the fact that the length of the needle needs
to be known for the efficient form of strstr, you can measure the length of the
haystack at the same time, and bail out as soon as the haystack is found to be
shorter than the needle.

Unless I'm mistaken, a similar approach could be used in strcoll: perform the
first-pass comparison at the same time the lengths are measured, and only
measure up to the shorter of the two lengths.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]