-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A cute numeral decoding trick (#67).
It turns out that you can map uppercase letters to lowercase letters, and vice versa, with a bitwise operation (e.g. x | 32). It works because they are offset by a power of two relative to each other in ASCII. This trick turns 3 branches into 2, which makes hexadecimal decoding a few % faster. Note that the uppercase to lowercase transformation is simpler to represent in code, becaue it's easier to set a bit than it is to clear a bit using integer literals. I also reworked the numeral decoding and encoding test suite while I was at it.
- Loading branch information
Showing
4 changed files
with
102 additions
and
61 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
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