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

Side by Side Diff: extensions/common/features/base_feature_provider.cc

Issue 2070283002: Use container::back() and container::pop_back(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/common/features/base_feature_provider.h" 5 #include "extensions/common/features/base_feature_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <stack> 9 #include <stack>
10 #include <utility> 10 #include <utility>
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 // Children of a given API are named starting with parent.name()+".", which 175 // Children of a given API are named starting with parent.name()+".", which
176 // means they'll be contiguous in the features_ std::map. 176 // means they'll be contiguous in the features_ std::map.
177 std::vector<Feature*> BaseFeatureProvider::GetChildren(const Feature& parent) 177 std::vector<Feature*> BaseFeatureProvider::GetChildren(const Feature& parent)
178 const { 178 const {
179 std::string prefix = parent.name() + "."; 179 std::string prefix = parent.name() + ".";
180 const FeatureMap::const_iterator first_child = features_.lower_bound(prefix); 180 const FeatureMap::const_iterator first_child = features_.lower_bound(prefix);
181 181
182 // All children have names before (parent.name() + ('.'+1)). 182 // All children have names before (parent.name() + ('.'+1)).
183 ++prefix[prefix.size() - 1]; 183 ++prefix.back();
184 const FeatureMap::const_iterator after_children = 184 const FeatureMap::const_iterator after_children =
185 features_.lower_bound(prefix); 185 features_.lower_bound(prefix);
186 186
187 std::vector<Feature*> result; 187 std::vector<Feature*> result;
188 result.reserve(std::distance(first_child, after_children)); 188 result.reserve(std::distance(first_child, after_children));
189 for (FeatureMap::const_iterator it = first_child; it != after_children; 189 for (FeatureMap::const_iterator it = first_child; it != after_children;
190 ++it) { 190 ++it) {
191 result.push_back(it->second.get()); 191 result.push_back(it->second.get());
192 } 192 }
193 return result; 193 return result;
194 } 194 }
195 195
196 } // namespace extensions 196 } // namespace extensions
OLDNEW
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.cc ('k') | google_apis/drive/drive_api_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698