Comment by emilfihlman
2 hours ago
I mean, isn't the trivial answer to just collapse the if else tree into just math that's evaluated always?
u32 a = (code <= 0x7F);
u32 b = (code <= 0x07FF);
u32 c = ((code < 0xD800) ||
(0xDFFF < code));
u32 d = (code <= 0xFFFF) * c;
u32 e = (code <= 0x10FFFF);
u32 v = (c && e);
return(-1 * !v + v * (4 - a - b - d));
Highly likely easy to optimise.
No comments yet
Contribute on Hacker News ↗