summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-05-13 09:19:16 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-05-17 13:20:25 -0700
commitfbb074a0890ccf5e82359f6c18e903c0c93b663d (patch)
tree519642241542eb531edb4739b0abca362872d155 /src
parentdb7445999016f97e790e0c55b36f0d94768a5fe3 (diff)
downloadqtlocation-mapboxgl-fbb074a0890ccf5e82359f6c18e903c0c93b663d.tar.gz
[core] Eliminate temporary vector in Style::queryRenderedFeatures
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/style.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 726b1f192b..88c08f1d20 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -318,24 +318,24 @@ RenderData Style::getRenderData() const {
}
std::vector<Feature> Style::queryRenderedFeatures(const StyleQueryParameters& parameters) const {
- std::vector<std::unordered_map<std::string, std::vector<Feature>>> sourceResults;
+ std::unordered_map<std::string, std::vector<Feature>> resultsByLayer;
+
for (const auto& source : sources) {
- sourceResults.emplace_back(source->queryRenderedFeatures(parameters));
+ auto sourceResults = source->queryRenderedFeatures(parameters);
+ std::move(sourceResults.begin(), sourceResults.end(), std::inserter(resultsByLayer, resultsByLayer.begin()));
}
- std::vector<Feature> features;
+ std::vector<Feature> result;
// Combine all results based on the style layer order.
for (const auto& layer : layers) {
- for (const auto& sourceResult : sourceResults) {
- auto it = sourceResult.find(layer->id);
- if (it != sourceResult.end()) {
- std::move(it->second.begin(), it->second.end(), std::back_inserter(features));
- }
+ auto it = resultsByLayer.find(layer->id);
+ if (it != resultsByLayer.end()) {
+ std::move(it->second.begin(), it->second.end(), std::back_inserter(result));
}
}
- return features;
+ return result;
}
float Style::getQueryRadius() const {