Created
August 18, 2020 03:52
-
-
Save sytranvn/1cf52f17733afde3e244cdffa63da94d to your computer and use it in GitHub Desktop.
Interesting C++ utils from V8 source code
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
// v8/utils | |
inline int HexValue(uc32 c) { | |
c -= '0'; | |
if (static_cast<unsigned>(c) <= 9) return c; | |
c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36. | |
if (static_cast<unsigned>(c) <= 5) return c + 10; | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment