slightly optimize bounding box computation for ArdourCanvas::PolyItem by avoiding inner conditional
This commit is contained in:
parent
170aee13eb
commit
621887cfaa
@ -37,27 +37,28 @@ PolyItem::PolyItem (Group* parent)
|
|||||||
void
|
void
|
||||||
PolyItem::compute_bounding_box () const
|
PolyItem::compute_bounding_box () const
|
||||||
{
|
{
|
||||||
bool have_one = false;
|
|
||||||
Rect bbox;
|
|
||||||
|
|
||||||
for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
|
if (!_points.empty()) {
|
||||||
if (have_one) {
|
|
||||||
|
Rect bbox;
|
||||||
|
Points::const_iterator i = _points.begin();
|
||||||
|
|
||||||
|
bbox.x0 = bbox.x1 = i->x;
|
||||||
|
bbox.y0 = bbox.y1 = i->y;
|
||||||
|
|
||||||
|
while (i != _points.end()) {
|
||||||
bbox.x0 = min (bbox.x0, i->x);
|
bbox.x0 = min (bbox.x0, i->x);
|
||||||
bbox.y0 = min (bbox.y0, i->y);
|
bbox.y0 = min (bbox.y0, i->y);
|
||||||
bbox.x1 = max (bbox.x1, i->x);
|
bbox.x1 = max (bbox.x1, i->x);
|
||||||
bbox.y1 = max (bbox.y1, i->y);
|
bbox.y1 = max (bbox.y1, i->y);
|
||||||
} else {
|
++i;
|
||||||
bbox.x0 = bbox.x1 = i->x;
|
|
||||||
bbox.y0 = bbox.y1 = i->y;
|
|
||||||
have_one = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!have_one) {
|
|
||||||
_bounding_box = boost::optional<Rect> ();
|
|
||||||
} else {
|
|
||||||
_bounding_box = bbox.expand (_outline_width / 2);
|
_bounding_box = bbox.expand (_outline_width / 2);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_bounding_box = boost::optional<Rect> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
_bounding_box_dirty = false;
|
_bounding_box_dirty = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user