Can you shrink it further?
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 10 08:37:09 PDT 2016
On Monday, 10 October 2016 at 15:17:05 UTC, Stefan Koch wrote:
> On Monday, 10 October 2016 at 03:55:17 UTC, Andrei Alexandrescu
> wrote:
>>
>> Oh, forgot to mention: the initial/short path should only
>> check for ASCII, i.e. c < 0x80. -- Andrei
Since in this case stability of min is concern, you can shave of
another 2 instructions by writing the comparison by hand
void popFront1(ref char[] s) @trusted pure nothrow {
immutable c = s[0];
size_t char_length = 1;
if (!(c & 0x80)) {
goto Lend;
} else {
import core.bitop;
uint i = 7u - bsr(~c | 1u);
import std.algorithm;
if (i > 6u) goto Lend;
char_length = i < s.length ? i : s.length;
}
Lend :
s = s.ptr[char_length .. s.length];
}
More information about the Digitalmars-d
mailing list