summaryrefslogtreecommitdiff
path: root/src/mbgl/style/paint_property.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-12-04 15:19:12 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-07 11:19:08 -0800
commit0a0007e0acdce85576857bec76e1333d771472f1 (patch)
tree07b0ecc27aa064332c989e50dcd2b4bf8942b8ad /src/mbgl/style/paint_property.hpp
parentfc0c839fc87088a9e3a3c0b6bd031544162b6ebf (diff)
downloadqtlocation-mapboxgl-0a0007e0acdce85576857bec76e1333d771472f1.tar.gz
[core] More efficient layer cloning
Diffstat (limited to 'src/mbgl/style/paint_property.hpp')
-rw-r--r--src/mbgl/style/paint_property.hpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp
index 710ce34a4f..f6ab430ed9 100644
--- a/src/mbgl/style/paint_property.hpp
+++ b/src/mbgl/style/paint_property.hpp
@@ -8,6 +8,7 @@
#include <mbgl/style/style_cascade_parameters.hpp>
#include <mbgl/style/style_calculation_parameters.hpp>
#include <mbgl/util/interpolate.hpp>
+#include <mbgl/util/std.hpp>
#include <rapidjson/document.h>
@@ -23,9 +24,8 @@ class PaintProperty {
public:
using Fn = Function<Result>;
- PaintProperty(T fallbackValue_)
- : fallbackValue(fallbackValue_),
- value(fallbackValue_) {
+ PaintProperty(T fallbackValue)
+ : value(fallbackValue) {
values.emplace(ClassID::Fallback, Fn(fallbackValue));
}
@@ -34,14 +34,8 @@ public:
transitions(other.transitions) {
}
- void operator=(const PaintProperty& other) {
- values = other.values;
- transitions = other.transitions;
- }
-
void parse(const char* name, const JSVal& layer) {
- values.clear();
- values.emplace(ClassID::Fallback, Fn(fallbackValue));
+ mbgl::util::erase_if(values, [] (const auto& p) { return p.first != ClassID::Fallback; });
std::string transitionName = { name };
transitionName += "-transition";
@@ -104,9 +98,9 @@ public:
return cascaded->prior.operator bool();
}
+ void operator=(const T& v) { values.emplace(ClassID::Default, Fn(v)); }
operator T() const { return value; }
- T fallbackValue;
std::map<ClassID, Fn> values;
std::map<ClassID, PropertyTransition> transitions;