Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 9f0f6e4

Browse files
n8shdlang-bot
authored andcommitted
Simplify dynamic array template constraint in core.internal.hash
Here it is convenient that `is(T == S[], S)` excludes enum types.
1 parent 3f4e8ca commit 9f0f6e4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/core/internal/hash.d

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,7 @@ if (!is(T == enum) && __traits(isStaticArray, T) && !canBitwiseHash!T)
194194

195195
//dynamic array hash
196196
size_t hashOf(T)(scope const T val, size_t seed = 0)
197-
if (!is(T == enum) && !is(T : typeof(null)) && is(T S: S[]) && !__traits(isStaticArray, T)
198-
&& !is(T == struct) && !is(T == class) && !is(T == union)
199-
&& (__traits(isScalar, S) || canBitwiseHash!S))
197+
if (is(T == S[], S) && (__traits(isScalar, S) || canBitwiseHash!S)) // excludes enum types
200198
{
201199
alias ElementType = typeof(val[0]);
202200
static if (!canBitwiseHash!ElementType)
@@ -222,9 +220,7 @@ if (!is(T == enum) && !is(T : typeof(null)) && is(T S: S[]) && !__traits(isStati
222220

223221
//dynamic array hash
224222
size_t hashOf(T)(T val, size_t seed = 0)
225-
if (!is(T == enum) && !is(T : typeof(null)) && is(T S: S[]) && !__traits(isStaticArray, T)
226-
&& !is(T == struct) && !is(T == class) && !is(T == union)
227-
&& !(__traits(isScalar, S) || canBitwiseHash!S))
223+
if (is(T == S[], S) && !(__traits(isScalar, S) || canBitwiseHash!S)) // excludes enum types
228224
{
229225
size_t hash = seed;
230226
foreach (ref o; val)

0 commit comments

Comments
 (0)