summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Wojciechowski <lucas@mapbox.com>2018-03-02 13:56:34 -0800
committerLucas Wojciechowski <lucas@mapbox.com>2018-03-07 11:46:17 -0800
commitc3eafed00c32bfcbd64475175ebc0c97df0dba9f (patch)
treedc0f892f81920f6801cf2c82a7500e70d4441cc2
parentbd9e8b615013af903884249da4054f969c8cfadc (diff)
downloadqtlocation-mapboxgl-c3eafed00c32bfcbd64475175ebc0c97df0dba9f.tar.gz
Addressed PR feedback
-rw-r--r--include/mbgl/style/filter.hpp4
-rw-r--r--src/mbgl/style/conversion/filter.cpp10
-rw-r--r--src/mbgl/style/filter.cpp2
3 files changed, 10 insertions, 6 deletions
diff --git a/include/mbgl/style/filter.hpp b/include/mbgl/style/filter.hpp
index 9347ae9381..00a8163667 100644
--- a/include/mbgl/style/filter.hpp
+++ b/include/mbgl/style/filter.hpp
@@ -236,7 +236,7 @@ public:
class ExpressionFilter {
public:
- std::shared_ptr<expression::Expression> expression;
+ std::shared_ptr<const expression::Expression> expression;
friend bool operator==(const ExpressionFilter& lhs, const ExpressionFilter& rhs) {
return *(lhs.expression) == *(rhs.expression);
@@ -274,7 +274,7 @@ using FilterBase = variant<
class Filter : public FilterBase {
public:
using FilterBase::FilterBase;
- bool operator()(expression::EvaluationContext context) const;
+ bool operator()(const expression::EvaluationContext &context) const;
};
} // namespace style
diff --git a/src/mbgl/style/conversion/filter.cpp b/src/mbgl/style/conversion/filter.cpp
index 75f6fffbae..fba149da12 100644
--- a/src/mbgl/style/conversion/filter.cpp
+++ b/src/mbgl/style/conversion/filter.cpp
@@ -18,9 +18,13 @@ static bool isExpressionFilter(const Convertible& filter) {
optional<std::string> op = toString(arrayMember(filter, 0));
- if (*op == "has") {
- auto operand = toString(arrayMember(filter, 1));
- return arrayLength(filter) >= 2 && operand && *operand != "$id" && *operand != "$type";
+ if (!op) {
+ return false;
+
+ } else if (*op == "has") {
+ if (arrayLength(filter) < 2) return false;
+ optional<std::string> operand = toString(arrayMember(filter, 1));
+ return operand && *operand != "$id" && *operand != "$type";
} else if (*op == "in" || *op == "!in" || *op == "!has" || *op == "none") {
return false;
diff --git a/src/mbgl/style/filter.cpp b/src/mbgl/style/filter.cpp
index 99d91cbcb4..51aa6bcf82 100644
--- a/src/mbgl/style/filter.cpp
+++ b/src/mbgl/style/filter.cpp
@@ -5,7 +5,7 @@
namespace mbgl {
namespace style {
-bool Filter::operator()(expression::EvaluationContext context) const {
+bool Filter::operator()(const expression::EvaluationContext &context) const {
return FilterBase::visit(*this, FilterEvaluator { context });
}