LibGfx: Minor IntRect::shatter and FloatRect::shatter optimization

All the shards always intersect unless they're empty.
So rather than checking for intersection, just check
whether they're empty or not.
This commit is contained in:
Tom 2020-07-14 10:15:56 -06:00 committed by Andreas Kling
parent cd8495f1d4
commit 7498024805
Notes: sideshowbarker 2024-07-19 04:49:26 +09:00
2 changed files with 8 additions and 8 deletions

View file

@ -96,13 +96,13 @@ Vector<FloatRect, 4> FloatRect::shatter(const FloatRect& hammer) const
right() - hammer.right(),
min((hammer.y() + hammer.height()), (y() + height())) - max(hammer.y(), y())
};
if (intersects(top_shard))
if (!top_shard.is_empty())
pieces.unchecked_append(top_shard);
if (intersects(bottom_shard))
if (!bottom_shard.is_empty())
pieces.unchecked_append(bottom_shard);
if (intersects(left_shard))
if (!left_shard.is_empty())
pieces.unchecked_append(left_shard);
if (intersects(right_shard))
if (!right_shard.is_empty())
pieces.unchecked_append(right_shard);
return pieces;

View file

@ -97,13 +97,13 @@ Vector<IntRect, 4> IntRect::shatter(const IntRect& hammer) const
right() - hammer.right(),
min((hammer.y() + hammer.height()), (y() + height())) - max(hammer.y(), y())
};
if (intersects(top_shard))
if (!top_shard.is_empty())
pieces.unchecked_append(top_shard);
if (intersects(bottom_shard))
if (!bottom_shard.is_empty())
pieces.unchecked_append(bottom_shard);
if (intersects(left_shard))
if (!left_shard.is_empty())
pieces.unchecked_append(left_shard);
if (intersects(right_shard))
if (!right_shard.is_empty())
pieces.unchecked_append(right_shard);
return pieces;