Can you shrink it further?
safety0ff via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 9 19:55:04 PDT 2016
On Sunday, 9 October 2016 at 22:11:50 UTC, Andrei Alexandrescu
wrote:
> I suspect there are cleverer things that can be done.
Less clever seemed to work for me:
void popFront1(ref char[] s) @trusted pure nothrow {
immutable c = s[0];
if (c < 0x80 || c >= 0xFE) {
s = s.ptr[1 .. s.length];
} else {
import core.bitop;
size_t i = 7u - bsr(~c); // N.B. changed uint to size_t
import std.algorithm;
s = s.ptr[min(i, s.length) .. s.length];
}
}
More information about the Digitalmars-d
mailing list