diff options
| author | Tobias Ellinghaus <me@houz.org> | 2017-07-05 11:46:26 +0000 |
|---|---|---|
| committer | Tobias Ellinghaus <me@houz.org> | 2017-07-05 11:46:26 +0000 |
| commit | 4f14bbfdaa090344772216ad3e89e19382a74a9c (patch) | |
| tree | 037254c143b472ce46b8686d18d15d74e3dfa92b /src | |
| parent | Clean up color profiles code (diff) | |
| download | inkscape-4f14bbfdaa090344772216ad3e89e19382a74a9c.tar.gz inkscape-4f14bbfdaa090344772216ad3e89e19382a74a9c.zip | |
Use std::transform instead of a for loop
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/document-properties.cpp | 13 | ||||
| -rw-r--r-- | src/ui/widget/color-icc-selector.cpp | 12 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 9dfae9a15..0fff45762 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -514,6 +514,9 @@ struct _cmp { } }; +template <typename From, typename To> +struct static_caster { To * operator () (From * value) const { return static_cast<To *>(value); } }; + void DocumentProperties::populate_linked_profiles_box() { _LinkedProfilesListStore->clear(); @@ -523,12 +526,10 @@ void DocumentProperties::populate_linked_profiles_box() } std::set<Inkscape::ColorProfile *, Inkscape::ColorProfile::pointerComparator> _current; - std::set<Inkscape::ColorProfile> foo; - for (auto &profile: current) { - SPObject* obj = profile; - Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); - _current.insert(prof); - } + std::transform(current.begin(), + current.end(), + std::inserter(_current, _current.begin()), + static_caster<SPObject, Inkscape::ColorProfile>()); for (auto &profile: _current) { Gtk::TreeModel::Row row = *(_LinkedProfilesListStore->append()); 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 <typename From, typename To> +struct static_caster { To * operator () (From * value) const { return static_cast<To *>(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<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); std::set<Inkscape::ColorProfile *, Inkscape::ColorProfile::pointerComparator> _current; - for (auto &it: current) { - SPObject* obj = it; - Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); - _current.insert(prof); - } + std::transform(current.begin(), + current.end(), + std::inserter(_current, _current.begin()), + static_caster<SPObject, Inkscape::ColorProfile>()); for (auto &it: _current) { Inkscape::ColorProfile *prof = it; |
