pdns icon indicating copy to clipboard operation
pdns copied to clipboard

Consider replacing strcasecmp calls

Open rgacogne opened this issue 3 years ago • 3 comments

  • Program: Authoritative, Recursor, dnsdist

Short description

Otto raised the fact that strcasecmp() is locale dependent and that it could lead to performance issues, in the comments of #11624. We should investigate how we can replace it to avoid any surprises.

rgacogne avatar May 31 '22 09:05 rgacogne

cf. https://daniel.haxx.se/blog/2022/05/19/case-insensitive-string-comparisons-in-c/

omoerbeek avatar May 31 '22 09:05 omoerbeek

Right, so it looks like strcasecmp can be slower with some locales because it is heavily optimized in some cases? Then we likely need to make sure that our version is not just slow in all cases ;)

rgacogne avatar May 31 '22 09:05 rgacogne

Or use OpenBSD :-)

     On OpenBSD, these functions always use the C locale and ignore the global
     locale, the thread-specific locale, and the locale argument.

omoerbeek avatar May 31 '22 09:05 omoerbeek