mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +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
Notes:
sideshowbarker
2024-07-19 04:49:26 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/74980248050 Pull-request: https://github.com/SerenityOS/serenity/pull/2798
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(),
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue