mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
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:
parent
cd8495f1d4
commit
7498024805
2 changed files with 8 additions and 8 deletions
|
@ -96,13 +96,13 @@ Vector<FloatRect, 4> FloatRect::shatter(const FloatRect& hammer) const
|
||||||
right() - hammer.right(),
|
right() - hammer.right(),
|
||||||
min((hammer.y() + hammer.height()), (y() + height())) - max(hammer.y(), y())
|
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);
|
pieces.unchecked_append(top_shard);
|
||||||
if (intersects(bottom_shard))
|
if (!bottom_shard.is_empty())
|
||||||
pieces.unchecked_append(bottom_shard);
|
pieces.unchecked_append(bottom_shard);
|
||||||
if (intersects(left_shard))
|
if (!left_shard.is_empty())
|
||||||
pieces.unchecked_append(left_shard);
|
pieces.unchecked_append(left_shard);
|
||||||
if (intersects(right_shard))
|
if (!right_shard.is_empty())
|
||||||
pieces.unchecked_append(right_shard);
|
pieces.unchecked_append(right_shard);
|
||||||
|
|
||||||
return pieces;
|
return pieces;
|
||||||
|
|
|
@ -97,13 +97,13 @@ Vector<IntRect, 4> IntRect::shatter(const IntRect& hammer) const
|
||||||
right() - hammer.right(),
|
right() - hammer.right(),
|
||||||
min((hammer.y() + hammer.height()), (y() + height())) - max(hammer.y(), y())
|
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);
|
pieces.unchecked_append(top_shard);
|
||||||
if (intersects(bottom_shard))
|
if (!bottom_shard.is_empty())
|
||||||
pieces.unchecked_append(bottom_shard);
|
pieces.unchecked_append(bottom_shard);
|
||||||
if (intersects(left_shard))
|
if (!left_shard.is_empty())
|
||||||
pieces.unchecked_append(left_shard);
|
pieces.unchecked_append(left_shard);
|
||||||
if (intersects(right_shard))
|
if (!right_shard.is_empty())
|
||||||
pieces.unchecked_append(right_shard);
|
pieces.unchecked_append(right_shard);
|
||||||
|
|
||||||
return pieces;
|
return pieces;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue