File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,13 @@ void DisjointRectSet::add(const Rect& new_rect)
15
15
void DisjointRectSet::shatter ()
16
16
{
17
17
Vector<Rect> output;
18
+ output.ensure_capacity (m_rects.size ());
18
19
bool pass_had_intersections = false ;
19
20
do {
20
21
pass_had_intersections = false ;
21
22
output.clear_with_capacity ();
22
23
for (size_t i = 0 ; i < m_rects.size (); ++i) {
23
24
auto & r1 = m_rects[i];
24
- bool r1_had_intersections = false ;
25
25
for (size_t j = 0 ; j < m_rects.size (); ++j) {
26
26
if (i == j)
27
27
continue ;
@@ -37,8 +37,7 @@ void DisjointRectSet::shatter()
37
37
output.append (m_rects[i]);
38
38
goto next_pass;
39
39
}
40
- if (!r1_had_intersections)
41
- output.append (r1);
40
+ output.append (r1);
42
41
}
43
42
next_pass:
44
43
swap (output, m_rects);
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ Vector<Rect> Rect::shatter(const Rect& hammer) const
39
39
Vector<Rect> pieces;
40
40
if (!intersects (hammer)) {
41
41
pieces.append (*this );
42
- pieces.append (hammer);
43
42
return pieces;
44
43
}
45
44
Rect top_shard {
@@ -63,7 +62,7 @@ Vector<Rect> Rect::shatter(const Rect& hammer) const
63
62
Rect right_shard {
64
63
hammer.x () + hammer.width (),
65
64
max (hammer.y (), y ()),
66
- ( x () + width () - 1 ) - ( hammer.x () + hammer. width () - 1 ),
65
+ right () - hammer.right ( ),
67
66
min ((hammer.y () + hammer.height ()), (y () + height ())) - max (hammer.y (), y ())
68
67
};
69
68
if (intersects (top_shard))
You can’t perform that action at this time.
0 commit comments