Eliding of slice range checking
Kagamin
spam at here.lot
Thu Oct 31 10:12:57 UTC 2019
On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote:
> 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;
> }
LDC is good at optimizing simple patterns, the only pitfall I
know is
https://forum.dlang.org/post/eoftnwkannqmubhjotat@forum.dlang.org
More information about the Digitalmars-d-learn
mailing list