remove reference initialization in header

This commit is contained in:
Filip Sykala 2021-09-10 13:09:45 +02:00
parent 77209abbcd
commit 999aef0440
3 changed files with 10 additions and 7 deletions
src/libslic3r

View file

@ -485,8 +485,11 @@ std::optional<Emboss::Glyph> Emboss::letter2glyph(const Font &font,
Polygons Emboss::text2polygons(const Font & font,
const char * text,
const FontProp &font_prop,
Glyphs & cache)
Glyphs * cache)
{
Glyphs tmp;
if (cache == nullptr) cache = &tmp;
std::optional<stbtt_fontinfo> font_info_opt;
Point cursor(0, 0);
@ -501,8 +504,8 @@ Polygons Emboss::text2polygons(const Font & font,
}
int unicode = static_cast<int>(wc);
std::optional<Glyph> glyph_opt;
auto glyph_item = cache.find(unicode);
if (glyph_item != cache.end()) glyph_opt = glyph_item->second;
auto glyph_item = cache->find(unicode);
if (glyph_item != cache->end()) glyph_opt = glyph_item->second;
else {
if (!font_info_opt.has_value()) {
font_info_opt = Privat::load_font_info(font);
@ -513,7 +516,7 @@ Polygons Emboss::text2polygons(const Font & font,
font_prop.flatness);
// has definition inside of font?
if (!glyph_opt.has_value()) continue;
cache[unicode] = *glyph_opt;
cache->operator[](unicode) = *glyph_opt;
}
// move glyph to cursor position