Replace is(Unqual!T == Unqual!U) with is(immutable T == immutable U) for speed & memory usage

This commit is contained in:
Nathan Sashihara 2020-08-02 09:54:29 -07:00 committed by The Dlang Bot
parent a4d8029c48
commit 453faadf5b
31 changed files with 169 additions and 173 deletions

View file

@ -623,7 +623,8 @@ if (isInputRange!R1 && isInputRange!R2)
static if (isDynamicArray!R1 && isDynamicArray!R2
&& __traits(isUnsigned, E1) && __traits(isUnsigned, E2)
&& E1.sizeof == 1 && E2.sizeof == 1
&& (is(Unqual!E1 == char) == is(Unqual!E2 == char))) // Both or neither must auto-decode.
// Both or neither must auto-decode.
&& (is(immutable E1 == immutable char) == is(immutable E2 == immutable char)))
{
// dstrcmp algorithm is correct for both ubyte[] and for char[].
import core.internal.string : dstrcmp;

View file

@ -5486,8 +5486,8 @@ if (isSomeString!Range ||
import std.uni : isWhite;
import std.traits : Unqual;
static if (is(Unqual!(ElementEncodingType!Range) == wchar) &&
is(Unqual!(ElementType!Range) == dchar))
static if (is(immutable ElementEncodingType!Range == immutable wchar) &&
is(immutable ElementType!Range == immutable dchar))
{
// all unicode whitespace characters fit into a wchar. However,
// this range is a wchar array, so we will treat it like a
@ -5500,8 +5500,8 @@ if (isSomeString!Range ||
break;
}
}
else static if (is(Unqual!(ElementType!Range) == dchar) ||
is(Unqual!(ElementType!Range) == wchar))
else static if (is(immutable ElementType!Range == immutable dchar) ||
is(immutable ElementType!Range == immutable wchar))
{
// dchar or wchar range, we can just use find.
auto r = find!(isWhite)(_s.save);

View file

@ -233,7 +233,7 @@ if (isInputRange!(Range) && is(typeof(r.front == lPar)))
{
size_t count;
static if (is(Unqual!(ElementEncodingType!Range) == Unqual!E) && isNarrowString!Range)
static if (is(immutable ElementEncodingType!Range == immutable E) && isNarrowString!Range)
{
import std.utf : byCodeUnit;
auto rn = r.byCodeUnit;
@ -1106,7 +1106,7 @@ if (isBidirectionalRange!R1 &&
enum isDefaultPred = false;
static if (isDefaultPred && isArray!R1 && isArray!R2 &&
is(Unqual!(ElementEncodingType!R1) == Unqual!(ElementEncodingType!R2)))
is(immutable ElementEncodingType!R1 == immutable ElementEncodingType!R2))
{
if (haystack.length < needle.length) return false;
@ -4614,7 +4614,7 @@ if (isInputRange!Range && Needles.length > 1 &&
template checkType(T)
{
enum checkType = is(Unqual!(ElementEncodingType!Range) == Unqual!T);
enum checkType = is(immutable ElementEncodingType!Range == immutable T);
}
// auto-decoding special case
@ -4719,7 +4719,7 @@ if (isInputRange!R1 &&
}
static if (isDefaultPred && isArray!R1 && isArray!R2 &&
is(Unqual!(ElementEncodingType!R1) == Unqual!(ElementEncodingType!R2)))
is(immutable ElementEncodingType!R1 == immutable ElementEncodingType!R2))
{
//Array slice comparison mode
return haystack[0 .. needle.length] == needle;