summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mbgl/style/conversion/filter.cpp9
-rw-r--r--src/mbgl/style/conversion/function.cpp2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/mbgl/style/conversion/filter.cpp b/src/mbgl/style/conversion/filter.cpp
index fc25ab0b0d..18a29ed808 100644
--- a/src/mbgl/style/conversion/filter.cpp
+++ b/src/mbgl/style/conversion/filter.cpp
@@ -118,7 +118,8 @@ ParseResult convertLiteral(const Convertible& convertible, Error& error) {
optional<std::vector<std::unique_ptr<Expression>>> convertLiteralArray(const Convertible &input, Error& error, std::size_t startIndex = 0) {
std::vector<std::unique_ptr<Expression>> output;
- for (std::size_t i = startIndex; i < arrayLength(input); i++) {
+ output.reserve(arrayLength(input));
+ for (std::size_t i = startIndex; i < arrayLength(input); ++i) {
ParseResult literal = convertLiteral(arrayMember(input, i), error);
if (!literal) {
return nullopt;
@@ -178,7 +179,8 @@ ParseResult convertLegacyInFilter(const Convertible& values, Error& error) {
optional<std::vector<std::unique_ptr<Expression>>> convertLegacyFilterArray(const Convertible &input, Error& error, std::size_t startIndex = 0) {
std::vector<std::unique_ptr<Expression>> output;
- for (std::size_t i = startIndex; i < arrayLength(input); i++) {
+ output.reserve(arrayLength(input));
+ for (std::size_t i = startIndex; i < arrayLength(input); ++i) {
optional<std::unique_ptr<Expression>> child = convertLegacyFilter(arrayMember(input, i), error);
if (!child) {
return nullopt;
@@ -225,7 +227,8 @@ optional<mbgl::Value> serializeLegacyFilter(const Convertible& values) {
return nullopt;
} else if (isArray(values)) {
std::vector<mbgl::Value> result;
- for (std::size_t i = 0; i < arrayLength(values); i++) {
+ result.reserve(arrayLength(values));
+ for (std::size_t i = 0; i < arrayLength(values); ++i) {
auto arrayValue = serializeLegacyFilter(arrayMember(values, i));
if (arrayValue) {
result.push_back(*arrayValue);
diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp
index 6ee962fb77..69fb0725d8 100644
--- a/src/mbgl/style/conversion/function.cpp
+++ b/src/mbgl/style/conversion/function.cpp
@@ -78,7 +78,7 @@ optional<PropertyExpression<T>> convertFunctionToExpression(const Convertible& v
return nullopt;
}
- optional<T> defaultValue;
+ optional<T> defaultValue{};
auto defaultValueValue = objectMember(value, "default");
if (defaultValueValue) {