Reduce the number of isAggregateType!T checks

Some are redundant. Others can be replaced by cheaper traits checks.
This commit is contained in:
Nathan Sashihara 2020-08-02 10:37:29 -07:00 committed by The Dlang Bot
parent 17ae8fc9be
commit 99e390486c
4 changed files with 23 additions and 26 deletions

View file

@ -635,13 +635,12 @@ bool isASCII(dchar c) @safe pure nothrow @nogc
auto toLower(C)(C c)
if (is(C : dchar))
{
import std.traits : isAggregateType, OriginalType, Unqual;
import std.traits : OriginalType;
alias OC = OriginalType!C;
static if (isAggregateType!OC)
static if (!__traits(isScalar, C))
alias R = dchar;
else
alias R = Unqual!OC;
else static if (is(immutable OriginalType!C == immutable OC, OC))
alias R = OC;
return isUpper(c) ? cast(R)(cast(R) c + 'a' - 'A') : cast(R) c;
}
@ -698,13 +697,12 @@ if (is(C : dchar))
auto toUpper(C)(C c)
if (is(C : dchar))
{
import std.traits : isAggregateType, OriginalType, Unqual;
import std.traits : OriginalType;
alias OC = OriginalType!C;
static if (isAggregateType!OC)
static if (!__traits(isScalar, C))
alias R = dchar;
else
alias R = Unqual!OC;
else static if (is(immutable OriginalType!C == immutable OC, OC))
alias R = OC;
return isLower(c) ? cast(R)(cast(R) c - ('a' - 'A')) : cast(R) c;
}