change render_thunk_list to std::list<render_thunk>

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.
This commit is contained in:
Mickey Rose 2017-01-03 20:53:55 +01:00
parent d3a9e4c4d7
commit 962bcf84c5
3 changed files with 6 additions and 7 deletions

View file

@ -42,9 +42,9 @@ struct render_thunk_list_dispatch
{ {
offset_ = offset; 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);
} }
} }

View file

@ -107,8 +107,7 @@ struct text_render_thunk : util::movable
using render_thunk = util::variant<vector_marker_render_thunk, using render_thunk = util::variant<vector_marker_render_thunk,
raster_marker_render_thunk, raster_marker_render_thunk,
text_render_thunk>; text_render_thunk>;
using render_thunk_ptr = std::unique_ptr<render_thunk>; using render_thunk_list = std::list<render_thunk>;
using render_thunk_list = std::list<render_thunk_ptr>;
} // namespace mapnik } // namespace mapnik

View file

@ -55,7 +55,7 @@ struct thunk_markers_renderer_context : markers_renderer_context
{ {
vector_marker_render_thunk thunk(src, attrs, marker_tr, params.opacity, vector_marker_render_thunk thunk(src, attrs, marker_tr, params.opacity,
comp_op_, params.snap_to_pixels); comp_op_, params.snap_to_pixels);
thunks_.push_back(std::make_unique<render_thunk>(std::move(thunk))); thunks_.emplace_back(std::move(thunk));
} }
virtual void render_marker(image_rgba8 const& src, 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, raster_marker_render_thunk thunk(src, marker_tr, params.opacity,
comp_op_, params.snap_to_pixels); comp_op_, params.snap_to_pixels);
thunks_.push_back(std::make_unique<render_thunk>(std::move(thunk))); thunks_.emplace_back(std::move(thunk));
} }
private: private:
@ -128,7 +128,7 @@ void render_thunk_extractor::extract_text_thunk(text_render_thunk::helper_ptr &&
halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL);
text_render_thunk thunk(std::move(helper), opacity, comp_op, halo_rasterizer); text_render_thunk thunk(std::move(helper), opacity, comp_op, halo_rasterizer);
thunks_.push_back(std::make_unique<render_thunk>(std::move(thunk))); thunks_.emplace_back(std::move(thunk));
update_box(); update_box();
} }