summaryrefslogtreecommitdiff
path: root/src/mbgl/layout/symbol_layout.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-09-13 14:07:43 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-16 09:00:55 -0700
commit32fac7cbe4d6b9c9434ffe0b2676df6dcf9931ee (patch)
treef30c4ca5763b5ab796e11b4ecfc1ec5f98e82a37 /src/mbgl/layout/symbol_layout.cpp
parenta8dd1bbbb8f9053923179fd45b2dfcbb86e3f474 (diff)
downloadqtlocation-mapboxgl-32fac7cbe4d6b9c9434ffe0b2676df6dcf9931ee.tar.gz
[core] Use optional to represent possible absence, not empty strings
Diffstat (limited to 'src/mbgl/layout/symbol_layout.cpp')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 5161d3c34b..84fd9393a2 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -91,11 +91,9 @@ SymbolLayout::SymbolLayout(std::string bucketName_,
ft.label = util::utf8_to_utf32::convert(u8string);
- if (!ft.label.empty()) {
- // Loop through all characters of this text and collect unique codepoints.
- for (char32_t chr : ft.label) {
- ranges.insert(getGlyphRange(chr));
- }
+ // Loop through all characters of this text and collect unique codepoints.
+ for (char32_t chr : *ft.label) {
+ ranges.insert(getGlyphRange(chr));
}
}
@@ -103,8 +101,7 @@ SymbolLayout::SymbolLayout(std::string bucketName_,
ft.sprite = util::replaceTokens(layout.iconImage, getValue);
}
- if (ft.label.length() || ft.sprite.length()) {
-
+ if (ft.label || ft.sprite) {
auto &multiline = ft.geometry;
GeometryCollection geometryCollection = feature->getGeometries();
@@ -194,9 +191,9 @@ void SymbolLayout::prepare(uintptr_t tileUID,
GlyphPositions face;
// if feature has text, shape the text
- if (feature.label.length()) {
+ if (feature.label) {
shapedText = glyphSet->getShaping(
- /* string */ feature.label,
+ /* string */ *feature.label,
/* maxWidth: ems */ layout.symbolPlacement != SymbolPlacementType::Line ?
layout.textMaxWidth * 24 : 0,
/* lineHeight: ems */ layout.textLineHeight * 24,
@@ -208,13 +205,13 @@ void SymbolLayout::prepare(uintptr_t tileUID,
// Add the glyphs we need for this label to the glyph atlas.
if (shapedText) {
- glyphAtlas.addGlyphs(tileUID, feature.label, layout.textFont, **glyphSet, face);
+ glyphAtlas.addGlyphs(tileUID, *feature.label, layout.textFont, **glyphSet, face);
}
}
// if feature has icon, get sprite atlas position
- if (feature.sprite.length()) {
- auto image = spriteAtlas.getImage(feature.sprite, SpritePatternMode::Single);
+ if (feature.sprite) {
+ auto image = spriteAtlas.getImage(*feature.sprite, SpritePatternMode::Single);
if (image) {
shapedIcon = shapeIcon(*image, layout);
assert((*image).spriteImage);