]> git.ipfire.org Git - thirdparty/glibc.git/commit
Simplify and speedup strstr/strcasestr first match
authorWilco Dijkstra <wdijkstr@arm.com>
Fri, 3 Aug 2018 16:24:12 +0000 (17:24 +0100)
committerWilco Dijkstra <wdijkstr@arm.com>
Fri, 13 Sep 2019 15:39:42 +0000 (16:39 +0100)
commitc60bf879b21aefedaf632f585b9c39af8532bc71
treebc71d628173e1f80bde5b07b2c17d5ef781c8c9e
parent55a280689e61cb8a7879ebbe0586d031559f1ba4
Simplify and speedup strstr/strcasestr first match

Looking at the benchtests, both strstr and strcasestr spend a lot of time
in a slow initialization loop handling one character per iteration.
This can be simplified and use the much faster strlen/strnlen/strchr/memcmp.
Read ahead a few cachelines to reduce the number of strnlen calls, which
improves performance by ~3-4%.  This patch improves the time taken for the
full strstr benchtest by >40%.

* string/strcasestr.c (STRCASESTR): Simplify and speedup first match.
* string/strstr.c (AVAILABLE): Likewise.

(cherry picked from commit 284f42bc778e487dfd5dff5c01959f93b9e0c4f5)
ChangeLog
string/strcasestr.c
string/strstr.c