Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit c5f0bd9

Browse files
authored
optimize operator== (#1765)
1 parent 40ff77b commit c5f0bd9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/ngraph/coordinate_transform.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,21 +456,21 @@ bool CoordinateTransform::Iterator::operator!=(const Iterator& it)
456456

457457
bool CoordinateTransform::Iterator::operator==(const Iterator& it)
458458
{
459-
if (m_target_shape != it.m_target_shape)
459+
if (it.m_oob)
460460
{
461-
return false;
462-
}
461+
// Out-of-bounds iterators are always equal; in other words, an iterator is always equal to
462+
// end() even if the internally stored coordinates are different.
463463

464-
// Out-of-bounds iterators are always equal; in other words, an iterator is always equal to
465-
// end() even if the internally stored coordinates are different.
466-
if (m_oob && it.m_oob)
464+
// If one iterator is out of bounds and the other is not, they are unequal even if their
465+
// target coordinates happen to match.
466+
return m_oob;
467+
}
468+
else if (m_oob)
467469
{
468-
return true;
470+
return false;
469471
}
470472

471-
// If one iterator is out of bounds and the other is not, they are unequal even if their target
472-
// coordinates happen to match.
473-
if (m_oob != it.m_oob)
473+
if (m_target_shape != it.m_target_shape)
474474
{
475475
return false;
476476
}

0 commit comments

Comments
 (0)