Unverified Commit c5f0bd9d authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

optimize operator== (#1765)

parent 40ff77bd
...@@ -456,21 +456,21 @@ bool CoordinateTransform::Iterator::operator!=(const Iterator& it) ...@@ -456,21 +456,21 @@ bool CoordinateTransform::Iterator::operator!=(const Iterator& it)
bool CoordinateTransform::Iterator::operator==(const Iterator& it) bool CoordinateTransform::Iterator::operator==(const Iterator& it)
{ {
if (m_target_shape != it.m_target_shape) if (it.m_oob)
{ {
return false;
}
// Out-of-bounds iterators are always equal; in other words, an iterator is always equal to // Out-of-bounds iterators are always equal; in other words, an iterator is always equal to
// end() even if the internally stored coordinates are different. // end() even if the internally stored coordinates are different.
if (m_oob && it.m_oob)
// If one iterator is out of bounds and the other is not, they are unequal even if their
// target coordinates happen to match.
return m_oob;
}
else if (m_oob)
{ {
return true; return false;
} }
// If one iterator is out of bounds and the other is not, they are unequal even if their target if (m_target_shape != it.m_target_shape)
// coordinates happen to match.
if (m_oob != it.m_oob)
{ {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment