Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strcase: some optimisations. #8875

Closed
wants to merge 1 commit into from
Closed

Conversation

gevaerts
Copy link
Contributor

Lookup tables for toupper() and tolower() make Curl_strcasecompare()
about 1.5 times faster. Reorganising Curl_strcasecompare() to fully
exit early then also allows simplifying the check at the end, for
another 15%. In total, the changes make Curl_strcasecompare() around
1.6 to 1.7 times faster.

Note that these optimisation assume ASCII. The original Curl_raw_toupper()
and raw_tolower() look like they already made that assumption, but confirmation would be good.

For short strings (I tested 4 to 8 characters) this is competitive with glibc, with this code being slightly faster on some CPUs and some lengths, and glibc being slightly faster on others. For longer strings glibc starts getting significantly faster (but the locale issue of course remains)

Lookup tables for toupper() and tolower() make Curl_strcasecompare()
about 1.5 times faster. Reorganising Curl_strcasecompare() to fully
exit early then also allows simplifying the check at the end, for
another 15%. In total, the changes make Curl_strcasecompare() around
1.6 to 1.7 times faster.

Note that these optimisation assume ASCII. The original Curl_raw_toupper()
and raw_tolower() look like they already made that assumption.
@bagder
Copy link
Member

bagder commented May 18, 2022

Confirmed: we only (need to) support ASCII with these.

@bagder
Copy link
Member

bagder commented May 19, 2022

Thanks!

@bagder bagder closed this in b12c2b9 May 19, 2022
@gevaerts gevaerts deleted the strcasecmp branch May 19, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants