diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2019-01-02 09:41:30 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marc@jeanmougin.fr> | 2019-01-02 09:41:30 +0000 |
| commit | 169dff19d4da8d76e69b8e896aa25b0013639c03 (patch) | |
| tree | a0c070fa95188b5cde708ac285e6a2db9df4a83f /src/display | |
| parent | Avoid creating a new document before opening an old document. (diff) | |
| download | inkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.tar.gz inkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.zip | |
modernize loops
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/cairo-utils.cpp | 12 | ||||
| -rw-r--r-- | src/display/canvas-arena.cpp | 4 | ||||
| -rw-r--r-- | src/display/canvas-temporary-item-list.cpp | 7 | ||||
| -rw-r--r-- | src/display/curve.cpp | 16 | ||||
| -rw-r--r-- | src/display/drawing-group.cpp | 38 | ||||
| -rw-r--r-- | src/display/drawing-item.cpp | 18 | ||||
| -rw-r--r-- | src/display/drawing-shape.cpp | 24 | ||||
| -rw-r--r-- | src/display/drawing-text.cpp | 16 | ||||
| -rw-r--r-- | src/display/drawing.cpp | 9 | ||||
| -rw-r--r-- | src/display/nr-filter-gaussian.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-filter-merge.cpp | 11 | ||||
| -rw-r--r-- | src/display/nr-filter-slot.cpp | 4 | ||||
| -rw-r--r-- | src/display/nr-filter-turbulence.cpp | 4 | ||||
| -rw-r--r-- | src/display/nr-filter.cpp | 26 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 16 |
15 files changed, 102 insertions, 105 deletions
diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 397d6d4b4..6dd343298 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -760,8 +760,8 @@ feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Affine const & tran Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1); // recurse to convert the new path resulting from the sbasis to svgd - for (Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) { - feed_curve_to_cairo(cr, *iter, trans, view, optimize_stroke); + for (const auto & iter : sbasis_path) { + feed_curve_to_cairo(cr, iter, trans, view, optimize_stroke); } } } @@ -845,8 +845,8 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Affi if (pathv.empty()) return; - for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { - feed_path_to_cairo(ct, *it, trans, area, optimize_stroke, stroke_width); + for(const auto & it : pathv) { + feed_path_to_cairo(ct, it, trans, area, optimize_stroke, stroke_width); } } @@ -858,8 +858,8 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv) if (pathv.empty()) return; - for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { - feed_path_to_cairo(ct, *it); + for(const auto & it : pathv) { + feed_path_to_cairo(ct, it); } } diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index fb20ccfe3..83693ea20 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -54,8 +54,8 @@ struct CachePrefObserver : public Inkscape::Preferences::Observer { { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); std::vector<Inkscape::Preferences::Entry> v = prefs->getAllEntries(observed_path); - for (unsigned i=0; i<v.size(); ++i) { - notify(v[i]); + for (const auto & i : v) { + notify(i); } prefs->addObserver(*this); } diff --git a/src/display/canvas-temporary-item-list.cpp b/src/display/canvas-temporary-item-list.cpp index ad112cdbb..caa960969 100644 --- a/src/display/canvas-temporary-item-list.cpp +++ b/src/display/canvas-temporary-item-list.cpp @@ -26,8 +26,7 @@ TemporaryItemList::TemporaryItemList(SPDesktop *desktop) TemporaryItemList::~TemporaryItemList() { // delete all items in list so the timeouts are removed - for ( std::list<TemporaryItem*>::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { - TemporaryItem * tempitem = *it; + for (auto tempitem : itemlist) { delete tempitem; } itemlist.clear(); @@ -49,8 +48,8 @@ TemporaryItemList::delete_item( TemporaryItem * tempitem ) { // check if the item is in the list, if so, delete it. (in other words, don't wait for the item to delete itself) bool in_list = false; - for ( std::list<TemporaryItem*>::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { - if ( *it == tempitem ) { + for (auto & it : itemlist) { + if ( it == tempitem ) { in_list = true; break; } diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 3391864ae..331701f27 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -158,9 +158,9 @@ SPCurve::split() const { std::list<SPCurve *> l; - for (Geom::PathVector::const_iterator path_it = _pathv.begin(); path_it != _pathv.end(); ++path_it) { + for (const auto & path_it : _pathv) { Geom::PathVector newpathv; - newpathv.push_back(*path_it); + newpathv.push_back(path_it); SPCurve * newcurve = new SPCurve(newpathv); l.push_back(newcurve); } @@ -327,8 +327,8 @@ SPCurve::is_closed() const return false; } - for (Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { - if ( ! it->closed() ) { + for (const auto & it : _pathv) { + if ( ! it.closed() ) { return false; } } @@ -531,8 +531,8 @@ SPCurve::append(SPCurve const *curve2, _pathv.push_back( (*it) ); } } else { - for (Geom::PathVector::const_iterator it = curve2->_pathv.begin(); it != curve2->_pathv.end(); ++it) { - _pathv.push_back( (*it) ); + for (const auto & it : curve2->_pathv) { + _pathv.push_back( it ); } } } @@ -658,10 +658,10 @@ size_t SPCurve::nodes_in_path() const { size_t nr = 0; - for(Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { + for(const auto & it : _pathv) { // if the path does not have any segments, it is a naked moveto, // and therefore any path has at least one valid node - size_t psize = std::max<size_t>(1, it->size_closed()); + size_t psize = std::max<size_t>(1, it.size_closed()); nr += psize; } diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 3a2eeb018..0d6a2edfc 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -73,14 +73,14 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u if (_child_transform) { child_ctx.ctm = *_child_transform * ctx.ctm; } - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->update(area, child_ctx, flags, reset); + for (auto & i : _children) { + i.update(area, child_ctx, flags, reset); } if (beststate & STATE_BBOX) { _bbox = Geom::OptIntRect(); - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - if (i->visible()) { - _bbox.unionWith(outline ? i->geometricBounds() : i->visualBounds()); + for (auto & i : _children) { + if (i.visible()) { + _bbox.unionWith(outline ? i.geometricBounds() : i.visualBounds()); } } } @@ -92,23 +92,23 @@ DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne { if (stop_at == nullptr) { // normal rendering - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->setAntialiasing(_antialias); - i->render(dc, area, flags, stop_at); + for (auto & i : _children) { + i.setAntialiasing(_antialias); + i.render(dc, area, flags, stop_at); } } else { // background rendering - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - if (&*i == stop_at) return RENDER_OK; // do not render the stop_at item at all - if (i->isAncestorOf(stop_at)) { + for (auto & i : _children) { + if (&i == stop_at) return RENDER_OK; // do not render the stop_at item at all + if (i.isAncestorOf(stop_at)) { // render its ancestors without masks, opacity or filters - i->setAntialiasing(_antialias); - i->render(dc, area, flags | RENDER_FILTER_BACKGROUND, stop_at); + i.setAntialiasing(_antialias); + i.render(dc, area, flags | RENDER_FILTER_BACKGROUND, stop_at); // stop further rendering return RENDER_OK; } else { - i->setAntialiasing(_antialias); - i->render(dc, area, flags, stop_at); + i.setAntialiasing(_antialias); + i.render(dc, area, flags, stop_at); } } } @@ -118,16 +118,16 @@ DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne void DrawingGroup::_clipItem(DrawingContext &dc, Geom::IntRect const &area) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->clip(dc, area); + for (auto & i : _children) { + i.clip(dc, area); } } DrawingItem * DrawingGroup::_pickItem(Geom::Point const &p, double delta, unsigned flags) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingItem *picked = i->pick(p, delta, flags); + for (auto & i : _children) { + DrawingItem *picked = i.pick(p, delta, flags); if (picked) { return _pick_children ? picked : this; } diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index d3729da94..6777be5cc 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -254,9 +254,9 @@ DrawingItem::clearChildren() // prevent children from referencing the parent during deletion // this way, children won't try to remove themselves from a list // from which they have already been removed by clear_and_dispose - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->_parent = NULL; - i->_child_type = CHILD_ORPHAN; + for (auto & i : _children) { + i._parent = NULL; + i._child_type = CHILD_ORPHAN; } _children.clear_and_dispose(DeleteDisposer()); _markForUpdate(STATE_ALL, false); @@ -418,8 +418,8 @@ void DrawingItem::setChildrenStyle(SPStyle* context_style) { _context_style = context_style; - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->setChildrenStyle( context_style ); + for (auto & i : _children) { + i.setChildrenStyle( context_style ); } } @@ -1053,8 +1053,8 @@ DrawingItem::recursivePrintTree( unsigned level ) std::cout << " "; } std::cout << name() << std::endl; - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->recursivePrintTree( level+1 ); + for (auto & i : _children) { + i.recursivePrintTree( level+1 ); } } @@ -1105,8 +1105,8 @@ DrawingItem::_invalidateFilterBackground(Geom::IntRect const &area) _cache->markDirty(area); } - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->_invalidateFilterBackground(area); + for (auto & i : _children) { + i._invalidateFilterBackground(area); } } diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index e1379a884..20544e1be 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -84,8 +84,8 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u unsigned beststate = STATE_ALL; // update markers - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->update(area, ctx, flags, reset); + for (auto & i : _children) { + i.update(area, ctx, flags, reset); } if (!(flags & STATE_RENDER)) { @@ -100,8 +100,8 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u } } if (beststate & STATE_BBOX) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - _bbox.unionWith(i->geometricBounds()); + for (auto & i : _children) { + _bbox.unionWith(i.geometricBounds()); } } } @@ -146,8 +146,8 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u } if (beststate & STATE_BBOX) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - _bbox.unionWith(i->geometricBounds()); + for (auto & i : _children) { + _bbox.unionWith(i.geometricBounds()); } } return STATE_ALL; @@ -206,8 +206,8 @@ void DrawingShape::_renderMarkers(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { // marker rendering - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->render(dc, area, flags, stop_at); + for (auto & i : _children) { + i.render(dc, area, flags, stop_at); } } @@ -289,8 +289,8 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne } // Handle different paint orders - for (unsigned i = 0; i < NRStyle::PAINT_ORDER_LAYERS; ++i) { - switch (_nrstyle.paint_order_layer[i]) { + for (auto & i : _nrstyle.paint_order_layer) { + switch (i) { case NRStyle::PAINT_ORDER_FILL: _renderFill(dc); break; @@ -412,8 +412,8 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) } // if not picked on the shape itself, try its markers - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingItem *ret = i->pick(p, delta, flags & ~PICK_STICKY); + for (auto & i : _children) { + DrawingItem *ret = i.pick(p, delta, flags & ~PICK_STICKY); if (ret) { _last_pick = this; return this; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index d809e8dcb..9d81d736d 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -446,8 +446,8 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are dc.setSource(rgba); dc.setTolerance(0.5); // low quality, but good enough for outline mode - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i); + for (auto & i : _children) { + DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&i); if (!g) throw InvalidItemException(); Inkscape::DrawingContext::Save save(dc); @@ -512,9 +512,9 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are double leftmost = DBL_MAX; bool first_y = true; double start_y = 0.0; - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + for (auto & i : _children) { - DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i); + DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&i); if (!g) throw InvalidItemException(); if (!invset) { @@ -576,8 +576,8 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are } // accumulate the path that represents the glyphs - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i); + for (auto & i : _children) { + DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&i); if (!g) throw InvalidItemException(); Inkscape::DrawingContext::Save save(dc); @@ -678,8 +678,8 @@ void DrawingText::_clipItem(DrawingContext &dc, Geom::IntRect const &/*area*/) } } - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i); + for (auto & i : _children) { + DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&i); if (!g) { throw InvalidItemException(); } diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index 3b41fc4c0..511de780a 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -146,10 +146,9 @@ void Drawing::setCacheLimit(Geom::OptIntRect const &r) { _cache_limit = r; - for (std::set<DrawingItem *>::iterator i = _cached_items.begin(); - i != _cached_items.end(); ++i) + for (auto _cached_item : _cached_items) { - (*i)->_markForUpdate(DrawingItem::STATE_CACHE, false); + _cached_item->_markForUpdate(DrawingItem::STATE_CACHE, false); } } void @@ -234,8 +233,8 @@ Drawing::_pickItemsForCaching() std::set_difference(_cached_items.begin(), _cached_items.end(), to_cache.begin(), to_cache.end(), std::inserter(to_uncache, to_uncache.end())); - for (std::set<DrawingItem*>::iterator j = to_uncache.begin(); j != to_uncache.end(); ++j) { - (*j)->setCached(false); + for (auto j : to_uncache) { + j->setCached(false); } } diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 3a1e4a621..d1dd976bb 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -482,7 +482,7 @@ gaussian_pass_IIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_su // Compute filter calcFilter(deviation, bf); - for(size_t i=0; i<N; i++) bf[i] = -bf[i]; + for(double & i : bf) i = -i; b[0] = 1; // b[0] == alpha (scaling coefficient) for(size_t i=0; i<N; i++) { b[i+1] = bf[i]; diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index fb2d6ba85..9ebfe4075 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -45,8 +45,8 @@ void FilterMerge::render_cairo(FilterSlot &slot) // output is RGBA if at least one input is RGBA bool rgba32 = false; cairo_surface_t *out = nullptr; - for (std::vector<int>::iterator i = _input_image.begin(); i != _input_image.end(); ++i) { - cairo_surface_t *in = slot.getcairo(*i); + for (int & i : _input_image) { + cairo_surface_t *in = slot.getcairo(i); if (cairo_surface_get_content(in) == CAIRO_CONTENT_COLOR_ALPHA) { out = ink_cairo_surface_create_identical(in); set_cairo_surface_ci( out, ci_fp ); @@ -60,8 +60,8 @@ void FilterMerge::render_cairo(FilterSlot &slot) } cairo_t *out_ct = cairo_create(out); - for (std::vector<int>::iterator i = _input_image.begin(); i != _input_image.end(); ++i) { - cairo_surface_t *in = slot.getcairo(*i); + for (int & i : _input_image) { + cairo_surface_t *in = slot.getcairo(i); set_cairo_surface_ci( in, ci_fp ); cairo_set_source_surface(out_ct, in, 0, 0); @@ -86,8 +86,7 @@ double FilterMerge::complexity(Geom::Affine const &) bool FilterMerge::uses_background() { - for (unsigned int i = 0; i < _input_image.size(); ++i) { - int input = _input_image[i]; + for (int input : _input_image) { if (input == NR_FILTER_BACKGROUNDIMAGE || input == NR_FILTER_BACKGROUNDALPHA) { return true; } diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 91a55639f..4d9dc239d 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -59,8 +59,8 @@ FilterSlot::FilterSlot(DrawingItem *item, DrawingContext *bgdc, FilterSlot::~FilterSlot() { - for (SlotMap::iterator i = _slots.begin(); i != _slots.end(); ++i) { - cairo_surface_destroy(i->second); + for (auto & _slot : _slots) { + cairo_surface_destroy(_slot.second); } } diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index e1b6fbfd3..91a71abcd 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -128,8 +128,8 @@ public: double y = p[Geom::Y] * _baseFreq[Geom::Y]; double ratio = 1.0; - for (int k = 0; k < 4; ++k) - pixel[k] = 0.0; + for (double & k : pixel) + k = 0.0; for(int octave = 0; octave < _octaves; ++octave) { diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index c6bbf3b81..eec7c1aa6 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -145,8 +145,8 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, D units.set_paraller(false); Geom::Affine pbtrans = units.get_matrix_display2pb(); - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (!_primitive[i]->can_handle_affine(pbtrans)) { + for (auto & i : _primitive) { + if (!i->can_handle_affine(pbtrans)) { units.set_paraller(true); break; } @@ -157,8 +157,8 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, D slot.set_blurquality(blurquality); slot.set_device_scale(graphic.surface()->device_scale()); - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - _primitive[i]->render_cairo(slot); + for (auto & i : _primitive) { + i->render_cairo(slot); } Geom::Point origin = graphic.targetLogicalBounds().min(); @@ -185,8 +185,8 @@ void Filter::set_primitive_units(SPFilterUnits unit) { } void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item) const { - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm()); + for (auto i : _primitive) { + if (i) i->area_enlarge(bbox, item->ctm()); } /* @@ -279,9 +279,9 @@ Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox) double Filter::complexity(Geom::Affine const &ctm) { double factor = 1.0; - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i]) { - double f = _primitive[i]->complexity(ctm); + for (auto & i : _primitive) { + if (i) { + double f = i->complexity(ctm); factor += (f - 1.0); } } @@ -290,8 +290,8 @@ double Filter::complexity(Geom::Affine const &ctm) bool Filter::uses_background() { - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i] && _primitive[i]->uses_background()) { + for (auto & i : _primitive) { + if (i && i->uses_background()) { return true; } } @@ -374,8 +374,8 @@ FilterPrimitive *Filter::get_primitive(int handle) { void Filter::clear_primitives() { - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - delete _primitive[i]; + for (auto & i : _primitive) { + delete i; } _primitive.clear(); } diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 331528654..e7ac1ab9b 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -827,8 +827,8 @@ void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsig SPCanvasGroup *group = SP_CANVAS_GROUP(item); Geom::OptRect bounds; - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *i = &(*it); + for (auto & item : group->items) { + SPCanvasItem *i = &item; sp_canvas_item_invoke_update (i, affine, flags); @@ -863,8 +863,8 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac *actual_item = nullptr; double dist = 0.0; - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *child = &(*it); + for (auto & it : group->items) { + SPCanvasItem *child = ⁢ if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) { SPCanvasItem *point_item = nullptr; // cater for incomplete item implementations @@ -897,8 +897,8 @@ void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf) { SPCanvasGroup *group = SP_CANVAS_GROUP(item); - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *child = &(*it); + for (auto & item : group->items) { + SPCanvasItem *child = &item; if (child->visible) { if ((child->x1 < buf->rect.right()) && (child->y1 < buf->rect.bottom()) && @@ -916,8 +916,8 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_ { SPCanvasGroup *group = SP_CANVAS_GROUP(item); - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *child = &(*it); + for (auto & item : group->items) { + SPCanvasItem *child = &item; if (child->visible) { if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) { SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area); |
