[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: glibc suggested speed improvement to strcasestr.c
From: |
Digital |
Subject: |
Fwd: glibc suggested speed improvement to strcasestr.c |
Date: |
Mon, 19 Apr 2004 18:37:43 -0700 |
User-agent: |
KMail/1.6.1 |
Hello address@hidden,
I did not see any response or acknowledgement from address@hidden
So I am re-sending this once again.
Attached you should find a suggested improvement for strcasestr.c which
should help speed it up a little. So instead of repeatedly doing a
tolower() call within the search loops, it does a onetime tolower() and
toupper() call outside the main search loops. this reduces the main loops
to simply comparing values without having to precalculate repeatedly.
To address@hidden,
I would like to eventually contribute a couple more string enhancements,
but according to the pages at the FSF it mentions something about needing
a signature for enhancements beyond 20 lines of code.
---------- Forwarded Message ----------
Subject: glibc suggested speed improvement to strcasestr.c
Date: Thursday 08 April 2004 01:49
From: Digital <address@hidden>
To: address@hidden
Reason for sending in this fix:
Looking at strcasestr.c, it appears that it can be made faster by removing
the calls to _tolower from the loops and doing a 1x pretest for upper and
lower case before looping.
I tried compiling the glibc-2.3 library while using mandrake 8 and ran
into trouble then, so I am no expert on configuring the library for
making a patch, but I did make an update (attached strcasestr.c) and
tested it separately, so it should be fairly easy to merge & test (for a
more experienced library maintainer) since I believe it is spellchecked,
tested, verified, ...except for the last step of actually testing within
the glib library as it should be done.
-------------3 files inside glibc-strcasestr.tar.gz--------
Included in this email is an updated version of strcasestr.c with the
faster looping method (replacing variables b & c with bl bu & cl cu
glibc-2.3.2 was used for creating this latest update to strcasestr.c
The current glibc strcasestr.c is located in:
glibc-2.3.2/sysdeps/generic/strcasestr.c
Also included is a diff file between the existing strcasestr.c found in
the library and the new attached strcasestr.c
this was made using the diff utility as:
diff glibc-2.3.2/sysdeps/generic/strcasestr.c strcasestr.c >>diff.txt
Final file included is strcasestrtest.c which was used to test
strcasestr.c Unfortunately, as mentioned earlier, I had trouble testing
glibc-2.3 using mandrake 8, therefore (even though I'm using mandrake 10
right now), I still thought it best to test it as a separate routine in
case I ran into trouble again :-(
---------------
I hope the improvement shown help strcasestr.c to search faster.
If you have any questions or suggestions, please send a reply, thanks.
glibc-strcasestr.tar.gz
Description: application/tgz