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

Reply via email to