Can you shrink it further?
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Wed Oct 12 05:31:35 PDT 2016
On 10/12/2016 04:56 AM, Matthias Bentrup wrote:
>
> void popFront1b(ref char[] s) @trusted pure nothrow {
> immutable c = cast(byte)s[0];
> if (c >= -8) {
> s = s[1 .. $];
> } else {
> uint i = 4 + (c + 64 >> 31) + (c + 32 >> 31) + (c + 16 >> 31);
> import std.algorithm;
> s = s[min(i, $) .. $];
> }
> }
This is really small although it does two jumps on the frequent path.
Perhaps an improvement over the current implementation. Nice work! -- Andrei
More information about the Digitalmars-d
mailing list