summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-01-16 00:07:45 +0000
committerYann Ylavic <ylavic@apache.org>2022-01-16 00:07:45 +0000
commit5d65f52a791345361a49521278db33e584fe7020 (patch)
tree7ec264fb00cb5e37d89390ce19a46b9b82236dcf /server
parent26a499102e1ffb70a8a4b54b6e3a1926a6547869 (diff)
downloadhttpd-5d65f52a791345361a49521278db33e584fe7020.tar.gz
util: Follow up to r1897101: Yet better ap_cstr_casecmp[n]().
This ones have a shorter prologue (-O2 still). Dump of assembler code for function ap_cstr_casecmp: 0x0000000000049fd0 <+0>: xor %edx,%edx 0x0000000000049fd2 <+2>: lea 0x3d567(%rip),%r8 # 0x87540 <ucharmap> 0x0000000000049fd9 <+9>: nopl 0x0(%rax) 0x0000000000049fe0 <+16>: movzbl (%rdi,%rdx,1),%eax 0x0000000000049fe4 <+20>: movzbl (%rsi,%rdx,1),%ecx 0x0000000000049fe8 <+24>: add $0x1,%rdx 0x0000000000049fec <+28>: movzbl (%r8,%rax,1),%eax 0x0000000000049ff1 <+33>: movzbl (%r8,%rcx,1),%ecx 0x0000000000049ff6 <+38>: cmp %ecx,%eax 0x0000000000049ff8 <+40>: jne 0x49ffe <ap_cstr_casecmp+46> 0x0000000000049ffa <+42>: test %eax,%eax 0x0000000000049ffc <+44>: jne 0x49fe0 <ap_cstr_casecmp+16> 0x0000000000049ffe <+46>: sub %ecx,%eax 0x000000000004a000 <+48>: ret End of assembler dump. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/util.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/server/util.c b/server/util.c
index c59f15d124..08eb7c51b0 100644
--- a/server/util.c
+++ b/server/util.c
@@ -3539,11 +3539,12 @@ static const unsigned char ucharmap[256] = {
AP_DECLARE(int) ap_cstr_casecmp(const char *s1, const char *s2)
{
- apr_size_t i = 0;
- for (;; ++i) {
- const int c1 = ucharmap[(unsigned char)s1[i]];
- const int c2 = ucharmap[(unsigned char)s2[i]];
- /* Not necessary to test for !c2, this is caught by c1 != c2 */
+ const unsigned char *u1 = (const unsigned char *)s1;
+ const unsigned char *u2 = (const unsigned char *)s2;
+ for (;;) {
+ const int c1 = ucharmap[*u1++];
+ const int c2 = ucharmap[*u2++];
+ /* Not necessary to test for !c2, this is caught by c1 == c2 */
if (c1 != c2 || !c1)
return c1 - c2;
}
@@ -3551,11 +3552,12 @@ AP_DECLARE(int) ap_cstr_casecmp(const char *s1, const char *s2)
AP_DECLARE(int) ap_cstr_casecmpn(const char *s1, const char *s2, apr_size_t n)
{
- apr_size_t i = 0;
- for (; i < n; ++i) {
- const int c1 = ucharmap[(unsigned char)s1[i]];
- const int c2 = ucharmap[(unsigned char)s2[i]];
- /* Not necessary to test for !c2, this is caught by c1 != c2 */
+ const unsigned char *u1 = (const unsigned char *)s1;
+ const unsigned char *u2 = (const unsigned char *)s2;
+ while (n--) {
+ const int c1 = ucharmap[*u1++];
+ const int c2 = ucharmap[*u2++];
+ /* Not necessary to test for !c2, this is caught by c1 == c2 */
if (c1 != c2 || !c1)
return c1 - c2;
}