You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use a branchless binary search for extension<->MIME-Types
This uses the excellent branchless binary search by Orlon Peters[1],
based on the Malte Skarupke's version[2] of Leonard E Shar's version of
a binary search. It's a fascinating implementation that ends up
becoming just a very tight loop using CMOV instructions, and finishing
with another CMOV instruction.
It's so clean that I removed the fast path using STRING_SWITCH as
that's not necessary anymore. A nice side effect of this change is
that the string "application/octet-stream" doesn't appear in the binary
anymore (except in the debug version due to assertions), as it's now
part of the compressed blob that mimegen generates.
A good segue to this commit would be porting the other usage of
bsearch() to this implementation.
[1] https://orlp.net/blog/bitwise-binary-search/
[2] https://probablydance.com/2023/04/27/beautiful-branchless-binary-search/
0 commit comments