]> git.ipfire.org Git - thirdparty/apache/httpd.git/commit
util: Improve ap_cstr_casecmp() and ap_cstr_casecmpn() performances.
authorYann Ylavic <ylavic@apache.org>
Sat, 15 Jan 2022 22:41:05 +0000 (22:41 +0000)
committerYann Ylavic <ylavic@apache.org>
Sat, 15 Jan 2022 22:41:05 +0000 (22:41 +0000)
commit26a499102e1ffb70a8a4b54b6e3a1926a6547869
tree2f401071e2980b87a2df26270329d5d934236d2e
parentade772aba50315bc69551ef6ed5763899854cf0d
util: Improve ap_cstr_casecmp() and ap_cstr_casecmpn() performances.

The new versions [1] compile to a shorter/faster assembly than the previous
ones [2], no functionnal change.

[1] ap_cstr_casecmp() after this commit:
Dump of assembler code for function ap_cstr_casecmp:
   0x0000000000049fc0 <+0>: movzbl (%rdi),%eax
   0x0000000000049fc3 <+3>: movzbl (%rsi),%edx
   0x0000000000049fc6 <+6>: lea    0x3d573(%rip),%r8        # 0x87540 <ucharmap>
   0x0000000000049fcd <+13>: movzbl (%r8,%rax,1),%eax
   0x0000000000049fd2 <+18>: movzbl (%r8,%rdx,1),%ecx
   0x0000000000049fd7 <+23>: cmp    %ecx,%eax
   0x0000000000049fd9 <+25>: jne    0x49ffe <ap_cstr_casecmp+62>
   0x0000000000049fdb <+27>: xor    %edx,%edx
   0x0000000000049fdd <+29>: jmp    0x49ffa <ap_cstr_casecmp+58>
   0x0000000000049fdf <+31>: nop
   0x0000000000049fe0 <+32>: add    $0x1,%rdx
   0x0000000000049fe4 <+36>: movzbl (%rdi,%rdx,1),%eax
   0x0000000000049fe8 <+40>: movzbl (%rsi,%rdx,1),%ecx
   0x0000000000049fec <+44>: movzbl (%r8,%rax,1),%eax
   0x0000000000049ff1 <+49>: movzbl (%r8,%rcx,1),%ecx
   0x0000000000049ff6 <+54>: cmp    %ecx,%eax
   0x0000000000049ff8 <+56>: jne    0x49ffe <ap_cstr_casecmp+62>
   0x0000000000049ffa <+58>: test   %eax,%eax
   0x0000000000049ffc <+60>: jne    0x49fe0 <ap_cstr_casecmp+32>
   0x0000000000049ffe <+62>: sub    %ecx,%eax
   0x000000000004a000 <+64>: ret
End of assembler dump.

[2] ap_cstr_casecmp() before this commit:
Dump of assembler code for function ap_cstr_casecmp:
   0x000000000004a000 <+0>: movzbl (%rdi),%eax
   0x000000000004a003 <+3>: movzbl (%rsi),%edx
   0x000000000004a006 <+6>: lea    0x3d533(%rip),%r8        # 0x87540 <ucharmap>
   0x000000000004a00d <+13>: mov    %rdi,%r9
   0x000000000004a010 <+16>: mov    %rax,%rcx
   0x000000000004a013 <+19>: movswl (%r8,%rdx,2),%edx
   0x000000000004a018 <+24>: movswl (%r8,%rax,2),%eax
   0x000000000004a01d <+29>: sub    %edx,%eax
   0x000000000004a01f <+31>: jne    0x4a052 <ap_cstr_casecmp+82>
   0x000000000004a021 <+33>: mov    $0x1,%edx
   0x000000000004a026 <+38>: test   %ecx,%ecx
   0x000000000004a028 <+40>: je     0x4a052 <ap_cstr_casecmp+82>
   0x000000000004a02a <+42>: nopw   0x0(%rax,%rax,1)
   0x000000000004a030 <+48>: movzbl (%r9,%rdx,1),%eax
   0x000000000004a035 <+53>: movzbl (%rsi,%rdx,1),%ecx
   0x000000000004a039 <+57>: add    $0x1,%rdx
   0x000000000004a03d <+61>: mov    %rax,%rdi
   0x000000000004a040 <+64>: movswl (%r8,%rcx,2),%ecx
   0x000000000004a045 <+69>: movswl (%r8,%rax,2),%eax
   0x000000000004a04a <+74>: sub    %ecx,%eax
   0x000000000004a04c <+76>: jne    0x4a052 <ap_cstr_casecmp+82>
   0x000000000004a04e <+78>: test   %edi,%edi
   0x000000000004a050 <+80>: jne    0x4a030 <ap_cstr_casecmp+48>
   0x000000000004a052 <+82>: ret
End of assembler dump.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897101 13f79535-47bb-0310-9956-ffa450edef68
server/util.c