Here's a baseline: http://goo.gl/91vIGc. Destroy!Andrei
Here's mine (the loop gets unrolled):
dchar front(const char[] s) {
assert(s.length > 0);
byte c = s[0];
dchar res = cast(ubyte)c;
if(c >= 0) {
return res;
}
c <<= 1;
assert(c < 0);
for(int i = 1; i < 4; i++) {
assert(i < s.length);
ubyte d = s[i];
assert((d >> 6) == 0b10);
res = (res << 8) | d;
c <<= 1;
if(c >= 0)
return res;
}
assert(false);
}
