summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression/comparison.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/expression/comparison.cpp')
-rw-r--r--src/mbgl/style/expression/comparison.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/mbgl/style/expression/comparison.cpp b/src/mbgl/style/expression/comparison.cpp
index aa5808a975..ca29ace0dd 100644
--- a/src/mbgl/style/expression/comparison.cpp
+++ b/src/mbgl/style/expression/comparison.cpp
@@ -22,30 +22,34 @@ static bool isComparableType(const std::string& op, const type::Type& type) {
}
}
-bool eq(Value a, Value b) { return a == b; }
-bool neq(Value a, Value b) { return a != b; }
-bool lt(Value lhs, Value rhs) {
+bool eq(const Value& a, const Value& b) {
+ return a == b;
+}
+bool neq(const Value& a, const Value& b) {
+ return a != b;
+}
+bool lt(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a < rhs.get<std::string>(); },
[&](double a) { return a < rhs.get<double>(); },
[&](const auto&) { assert(false); return false; }
);
}
-bool gt(Value lhs, Value rhs) {
+bool gt(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a > rhs.get<std::string>(); },
[&](double a) { return a > rhs.get<double>(); },
[&](const auto&) { assert(false); return false; }
);
}
-bool lteq(Value lhs, Value rhs) {
+bool lteq(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a <= rhs.get<std::string>(); },
[&](double a) { return a <= rhs.get<double>(); },
[&](const auto&) { assert(false); return false; }
);
}
-bool gteq(Value lhs, Value rhs) {
+bool gteq(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a >= rhs.get<std::string>(); },
[&](double a) { return a >= rhs.get<double>(); },
@@ -53,12 +57,24 @@ bool gteq(Value lhs, Value rhs) {
);
}
-bool eqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) == 0; }
-bool neqCollate(std::string a, std::string b, Collator c) { return !eqCollate(a, b, c); }
-bool ltCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) < 0; }
-bool gtCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) > 0; }
-bool lteqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) <= 0; }
-bool gteqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) >= 0; }
+bool eqCollate(const std::string& a, const std::string& b, const Collator& c) {
+ return c.compare(a, b) == 0;
+}
+bool neqCollate(const std::string& a, const std::string& b, const Collator& c) {
+ return !eqCollate(a, b, c);
+}
+bool ltCollate(const std::string& a, const std::string& b, const Collator& c) {
+ return c.compare(a, b) < 0;
+}
+bool gtCollate(const std::string& a, const std::string& b, const Collator& c) {
+ return c.compare(a, b) > 0;
+}
+bool lteqCollate(const std::string& a, const std::string& b, const Collator& c) {
+ return c.compare(a, b) <= 0;
+}
+bool gteqCollate(const std::string& a, const std::string& b, const Collator& c) {
+ return c.compare(a, b) >= 0;
+}
static BasicComparison::CompareFunctionType getBasicCompareFunction(const std::string& op) {
if (op == "==") return eq;