mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Compare all available lengths prior to entering the loop
This commit is contained in:
parent
963274f1c1
commit
c21f0ea8eb
1 changed files with 17 additions and 4 deletions
|
@ -1003,10 +1003,23 @@ template equal(alias pred = "a == b")
|
|||
}
|
||||
else
|
||||
{
|
||||
static if (allSatisfy!(hasLength, Ranges))
|
||||
static foreach (r; rs[1 .. $])
|
||||
if (rs[0].length != r.length)
|
||||
return false;
|
||||
static foreach (i, R; Ranges)
|
||||
{
|
||||
static if (hasLength!R)
|
||||
{
|
||||
static if (!is(typeof(firstWithLength)))
|
||||
{
|
||||
// Found the first range that has length
|
||||
enum firstWithLength = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compare the length of the current range against the first with length
|
||||
if (rs[firstWithLength].length != rs[i].length)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return equalLoop(rs);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue