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

Unified Diff: base/values.cc

Issue 7618021: base: Fix the TODO in ListValue::Remove(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 9 years, 4 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 | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index b215812c3f6eb638923218620e8fe704dd96877a..7a364bd8ff0f14402dac1ff80b5f6b72b656a9d2 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -818,21 +818,19 @@ bool ListValue::Remove(size_t index, Value** out_value) {
return true;
}
-int ListValue::Remove(const Value& value) {
+bool ListValue::Remove(const Value& value, size_t* index) {
for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) {
if ((*i)->Equals(&value)) {
- size_t index = i - list_.begin();
+ size_t previous_index = i - list_.begin();
delete *i;
list_.erase(i);
- // TODO(anyone): Returning a signed int type here is just wrong.
- // Change this interface to return a size_t.
- DCHECK(index <= INT_MAX);
- int return_index = static_cast<int>(index);
- return return_index;
+ if (index)
+ *index = previous_index;
+ return true;
}
}
- return -1;
+ return false;
}
void ListValue::Append(Value* in_value) {
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698