Skip to content

Instantly share code, notes, and snippets.

@sytranvn
Created August 18, 2020 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sytranvn/1cf52f17733afde3e244cdffa63da94d to your computer and use it in GitHub Desktop.
Save sytranvn/1cf52f17733afde3e244cdffa63da94d to your computer and use it in GitHub Desktop.
Interesting C++ utils from V8 source code
// 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