From fbd983f1048a0fb399d0e77b3c165a66268e7cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 3 Jun 2014 18:11:19 +0200 Subject: [PATCH] don't make a copy of the glyph store --- src/map/tile_parser.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index ad0fb2d71..2af5278f5 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -49,12 +49,15 @@ bool TileParser::obsolete() const { return tile.state == TileData::State::obsole void TileParser::addGlyph(uint64_t tileid, const std::string stackname, const std::u32string &string, const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face) { - std::map sdfs = fontStack.getSDFs(); + const std::map &sdfs = fontStack.getSDFs(); // Loop through all characters and add glyph to atlas, positions. for (uint32_t chr : string) { - const SDFGlyph sdf = sdfs[chr]; - const Rect rect = glyphAtlas.addGlyph(tileid, stackname, sdf); - face.emplace(chr, Glyph{rect, sdf.metrics}); + auto sdf_it = sdfs.find(chr); + if (sdf_it != sdfs.end()) { + const SDFGlyph& sdf = sdf_it->second; + const Rect rect = glyphAtlas.addGlyph(tileid, stackname, sdf); + face.emplace(chr, Glyph{rect, sdf.metrics}); + } } }