-
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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/
- Loading branch information
Showing
2 changed files
with
48 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters