From 962bcf84c5f179f97cb948ec70cd34a32bc91355 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Tue, 3 Jan 2017 20:53:55 +0100 Subject: [PATCH] change render_thunk_list to std::list Wrapping render_thunk in std::unique_ptr is one extra allocation per element, with no purpose. The somewhat costly xyz_render_thunk move constructor is only called once upon insertion, regardless of whether we're emplacing render_thunk or unique_ptr. --- include/mapnik/renderer_common/render_group_symbolizer.hpp | 4 ++-- include/mapnik/renderer_common/render_thunk.hpp | 3 +-- src/renderer_common/render_thunk_extractor.cpp | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/mapnik/renderer_common/render_group_symbolizer.hpp b/include/mapnik/renderer_common/render_group_symbolizer.hpp index e7b1b2248..65cc0f94f 100644 --- a/include/mapnik/renderer_common/render_group_symbolizer.hpp +++ b/include/mapnik/renderer_common/render_group_symbolizer.hpp @@ -42,9 +42,9 @@ struct render_thunk_list_dispatch { offset_ = offset; - for (render_thunk_ptr const& thunk : thunks) + for (render_thunk const& thunk : thunks) { - util::apply_visitor(std::ref(*this), *thunk); + util::apply_visitor(std::ref(*this), thunk); } } diff --git a/include/mapnik/renderer_common/render_thunk.hpp b/include/mapnik/renderer_common/render_thunk.hpp index 2a957d260..66b108bb9 100644 --- a/include/mapnik/renderer_common/render_thunk.hpp +++ b/include/mapnik/renderer_common/render_thunk.hpp @@ -107,8 +107,7 @@ struct text_render_thunk : util::movable using render_thunk = util::variant; -using render_thunk_ptr = std::unique_ptr; -using render_thunk_list = std::list; +using render_thunk_list = std::list; } // namespace mapnik diff --git a/src/renderer_common/render_thunk_extractor.cpp b/src/renderer_common/render_thunk_extractor.cpp index c437262da..1a5d1b854 100644 --- a/src/renderer_common/render_thunk_extractor.cpp +++ b/src/renderer_common/render_thunk_extractor.cpp @@ -55,7 +55,7 @@ struct thunk_markers_renderer_context : markers_renderer_context { vector_marker_render_thunk thunk(src, attrs, marker_tr, params.opacity, comp_op_, params.snap_to_pixels); - thunks_.push_back(std::make_unique(std::move(thunk))); + thunks_.emplace_back(std::move(thunk)); } virtual void render_marker(image_rgba8 const& src, @@ -64,7 +64,7 @@ struct thunk_markers_renderer_context : markers_renderer_context { raster_marker_render_thunk thunk(src, marker_tr, params.opacity, comp_op_, params.snap_to_pixels); - thunks_.push_back(std::make_unique(std::move(thunk))); + thunks_.emplace_back(std::move(thunk)); } private: @@ -128,7 +128,7 @@ void render_thunk_extractor::extract_text_thunk(text_render_thunk::helper_ptr && halo_rasterizer_enum halo_rasterizer = get(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); text_render_thunk thunk(std::move(helper), opacity, comp_op, halo_rasterizer); - thunks_.push_back(std::make_unique(std::move(thunk))); + thunks_.emplace_back(std::move(thunk)); update_box(); }