Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(697)

Unified Diff: extensions/common/features/base_feature_provider.cc

Issue 1772683002: FeatureProvider returns std::map instead of vector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/features/base_feature_provider.h ('k') | extensions/common/features/feature_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/base_feature_provider.cc
diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/base_feature_provider.cc
index 8bcec82ce3d0071880feedbc580b7da2bb8984c5..069de389158c2882040eb2224425f3ad3854fcf9 100644
--- a/extensions/common/features/base_feature_provider.cc
+++ b/extensions/common/features/base_feature_provider.cc
@@ -149,19 +149,12 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
BaseFeatureProvider::~BaseFeatureProvider() {
}
-const std::vector<std::string>& BaseFeatureProvider::GetAllFeatureNames()
- const {
- if (feature_names_.empty()) {
- for (const auto& feature : features_)
- feature_names_.push_back(feature.first);
- // A std::map is sorted by its keys, so we don't need to sort feature_names_
- // now.
- }
- return feature_names_;
+const FeatureMap& BaseFeatureProvider::GetAllFeatures() const {
+ return features_;
}
Feature* BaseFeatureProvider::GetFeature(const std::string& name) const {
- const auto iter = features_.find(name);
+ FeatureMap::const_iterator iter = features_.find(name);
if (iter != features_.end())
return iter->second.get();
else
@@ -186,15 +179,17 @@ Feature* BaseFeatureProvider::GetParent(Feature* feature) const {
std::vector<Feature*> BaseFeatureProvider::GetChildren(const Feature& parent)
const {
std::string prefix = parent.name() + ".";
- const auto first_child = features_.lower_bound(prefix);
+ const FeatureMap::const_iterator first_child = features_.lower_bound(prefix);
// All children have names before (parent.name() + ('.'+1)).
++prefix[prefix.size() - 1];
- const auto after_children = features_.lower_bound(prefix);
+ const FeatureMap::const_iterator after_children =
+ features_.lower_bound(prefix);
std::vector<Feature*> result;
result.reserve(std::distance(first_child, after_children));
- for (auto it = first_child; it != after_children; ++it) {
+ for (FeatureMap::const_iterator it = first_child; it != after_children;
+ ++it) {
result.push_back(it->second.get());
}
return result;
« no previous file with comments | « extensions/common/features/base_feature_provider.h ('k') | extensions/common/features/feature_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698