From 3e50850260db13ec63ce4ca0e47e7fd7e30ce484 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Wed, 26 Jul 2017 20:12:48 +0200 Subject: TileLayer: use shared_ptr for FrameSpec vector (#6171) * TileLayer: use shared_ptr for vector framespec This reduce memory copy of TileLayer from (4 to 16) * FrameSpec where FrameSpec = (sizeof(int) + 3 * sizeof(ptr)) to int + sizeof(ptr) Callgrind difference Before: https://lut.im/RGkiJqQb8T/LeQIEXpAuRzfl7gd.png After: https://lut.im/bcqmwee1xu/cTwtptY5tRuS9lp0.png * Fix one push_back to use vector::emplace_back & optimize inclusions --- src/client/tile.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/client') diff --git a/src/client/tile.h b/src/client/tile.h index aadc3e156..cfdcf30bd 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #include "util/numeric.h" class IGameDef; @@ -284,7 +285,7 @@ struct TileLayer //! If true, the tile has its own color. bool has_color = false; - std::vector frames; + std::shared_ptr> frames = nullptr; /*! * The color of the tile, or if the tile does not own -- cgit v1.2.3