Does DMD/LDC avoid range-checking in slice-expressions such as the one in my array-overload of `startsWith` defined as

bool startsWith(T)(scope const(T)[] haystack,
                   scope const(T)[] needle)
{
    if (haystack.length >= needle.length)
    {
return haystack[0 .. needle.length] == needle; // is slice range checking avoid here?
    }
    return false;
}

///
@safe pure nothrow @nogc unittest
{
    auto x = "beta version";
    assert(x.startsWith("beta"));
}

when building in release mode?

I remember a DMD pull from Ian Buclaw that enabled some eliding but I don't remember if it includes the case above.

How can I investigate the codegen myself here?

Reply via email to