From 60d9032701e657344bafda8895bf073e28bab5ae Mon Sep 17 00:00:00 2001 From: Tobias Ellinghaus Date: Wed, 5 Jul 2017 12:10:59 +0200 Subject: Clean up color profiles code This is a late 2nd part for 86a74b4a93ab62c8ef7819dc549fe7b3ace24916 and gets rid of the non-descriptive std::pair --- src/ui/widget/color-icc-selector.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 616e9afa8..7928311d5 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -680,10 +680,16 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const &name) int index = 1; std::vector current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); - std::set _current(current.begin(), current.end()); - for (std::set::const_iterator it = _current.begin(); it != _current.end(); ++it) { - SPObject *obj = *it; - Inkscape::ColorProfile *prof = reinterpret_cast(obj); + + std::set _current; + for (auto &it: current) { + SPObject* obj = it; + Inkscape::ColorProfile* prof = reinterpret_cast(obj); + _current.insert(prof); + } + + for (auto &it: _current) { + Inkscape::ColorProfile *prof = it; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); -- cgit v1.2.3 From 4f14bbfdaa090344772216ad3e89e19382a74a9c Mon Sep 17 00:00:00 2001 From: Tobias Ellinghaus Date: Wed, 5 Jul 2017 13:46:26 +0200 Subject: Use std::transform instead of a for loop --- src/ui/widget/color-icc-selector.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 7928311d5..f1dd92746 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -663,6 +663,9 @@ struct _cmp { } }; +template +struct static_caster { To * operator () (From * value) const { return static_cast(value); } }; + void ColorICCSelectorImpl::_profilesChanged(std::string const &name) { GtkComboBox *combo = GTK_COMBO_BOX(_profileSel); @@ -682,11 +685,10 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const &name) std::vector current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); std::set _current; - for (auto &it: current) { - SPObject* obj = it; - Inkscape::ColorProfile* prof = reinterpret_cast(obj); - _current.insert(prof); - } + std::transform(current.begin(), + current.end(), + std::inserter(_current, _current.begin()), + static_caster()); for (auto &it: _current) { Inkscape::ColorProfile *prof = it; -- cgit v1.2.3