This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/15884] Big performance problem in strcoll
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Sat, 24 Aug 2013 20:20:56 +0000
- Subject: [Bug libc/15884] Big performance problem in strcoll
- Auto-submitted: auto-generated
- References: <bug-15884-131 at http dot sourceware dot org/bugzilla/>
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.