From d58bee6d90c7627d9059466f818bd296b01755ce Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 28 Jun 2016 15:16:34 -0700 Subject: [core] Avoid unnecessary copies in GlyphSet::insert --- src/mbgl/text/glyph_pbf.cpp | 2 +- src/mbgl/text/glyph_set.cpp | 6 +++--- src/mbgl/text/glyph_set.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mbgl/text/glyph_pbf.cpp b/src/mbgl/text/glyph_pbf.cpp index 9046464c5c..b4dac4ce01 100644 --- a/src/mbgl/text/glyph_pbf.cpp +++ b/src/mbgl/text/glyph_pbf.cpp @@ -53,7 +53,7 @@ void parseGlyphPBF(mbgl::GlyphSet& glyphSet, const std::string& data) { } } - glyphSet.insert(glyph.id, glyph); + glyphSet.insert(glyph.id, std::move(glyph)); } } } diff --git a/src/mbgl/text/glyph_set.cpp b/src/mbgl/text/glyph_set.cpp index 8bd7e4ae03..0875a83850 100644 --- a/src/mbgl/text/glyph_set.cpp +++ b/src/mbgl/text/glyph_set.cpp @@ -6,11 +6,11 @@ namespace mbgl { -void GlyphSet::insert(uint32_t id, const SDFGlyph &glyph) { +void GlyphSet::insert(uint32_t id, SDFGlyph&& glyph) { auto it = sdfs.find(id); if (it == sdfs.end()) { // Glyph doesn't exist yet. - sdfs.emplace(id, glyph); + sdfs.emplace(id, std::move(glyph)); } else if (it->second.metrics == glyph.metrics) { if (it->second.bitmap != glyph.bitmap) { // The actual bitmap was updated; this is unsupported. @@ -18,7 +18,7 @@ void GlyphSet::insert(uint32_t id, const SDFGlyph &glyph) { } // At least try to update it in case it's currently unsused. // If it is already used; we won't attempt to update the glyph atlas texture. - it->second.bitmap = glyph.bitmap; + it->second.bitmap = std::move(glyph.bitmap); } else { // The metrics were updated; this is unsupported. Log::Warning(Event::Glyph, "Modified glyph has different metrics"); diff --git a/src/mbgl/text/glyph_set.hpp b/src/mbgl/text/glyph_set.hpp index 77e2cb1c95..37ffdb070a 100644 --- a/src/mbgl/text/glyph_set.hpp +++ b/src/mbgl/text/glyph_set.hpp @@ -7,7 +7,7 @@ namespace mbgl { class GlyphSet { public: - void insert(uint32_t id, const SDFGlyph &glyph); + void insert(uint32_t id, SDFGlyph&&); const std::map &getSDFs() const; const Shaping getShaping(const std::u32string &string, float maxWidth, float lineHeight, float horizontalAlign, float verticalAlign, float justify, -- cgit v1.2.1