diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 23:37:02 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 23:37:02 +0000 |
commit | 17350d35a047286d79010e0abfea3d84722d3dc7 (patch) | |
tree | 273c226b2d0eebdbb287dc04f260c7541775b297 | |
parent | bd52a98b4ef0149a544c45a3dbf870ce3f384688 (diff) | |
download | chromium_src-17350d35a047286d79010e0abfea3d84722d3dc7.zip chromium_src-17350d35a047286d79010e0abfea3d84722d3dc7.tar.gz chromium_src-17350d35a047286d79010e0abfea3d84722d3dc7.tar.bz2 |
Make SplitString() and variants clear their outparam vector. (Note that SplitStringIntoKeyValues() and SplitStringIntoKeyValuePairs() already did this.) This is more in line with what other APIs that take outparams do.
I audited all callers, and the only ones affected by this are the buggy ones in bug 134695 that already wanted this behavior, as well as the couple of places in this CL that were manually calling clear() and now don't have to.
BUG=134695
TEST=none
TBR=brettw,phajdan.jr
Review URL: https://chromiumcodereview.appspot.com/10684003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144323 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/string_split.cc | 3 | ||||
-rw-r--r-- | base/string_split.h | 8 | ||||
-rw-r--r-- | base/string_split_unittest.cc | 3 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_vms.cc | 3 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list_win.cc | 2 |
5 files changed, 8 insertions, 11 deletions
diff --git a/base/string_split.cc b/base/string_split.cc index ea694d5..e5befcf 100644 --- a/base/string_split.cc +++ b/base/string_split.cc @@ -16,6 +16,7 @@ static void SplitStringT(const STR& str, const typename STR::value_type s, bool trim_whitespace, std::vector<STR>* r) { + r->clear(); size_t last = 0; size_t c = str.size(); for (size_t i = 0; i <= c; ++i) { @@ -115,6 +116,7 @@ template <typename STR> static void SplitStringUsingSubstrT(const STR& str, const STR& s, std::vector<STR>* r) { + r->clear(); typename STR::size_type begin_index = 0; while (true) { const typename STR::size_type end_index = str.find(s, begin_index); @@ -165,6 +167,7 @@ void SplitStringDontTrim(const std::string& str, template<typename STR> void SplitStringAlongWhitespaceT(const STR& str, std::vector<STR>* result) { + result->clear(); const size_t length = str.length(); if (!length) return; diff --git a/base/string_split.h b/base/string_split.h index 6c7895d..32f6d8d 100644 --- a/base/string_split.h +++ b/base/string_split.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,9 +15,9 @@ namespace base { -// Splits |str| into a vector of strings delimited by |s|. Append the results -// into |r| as they appear. If several instances of |s| are contiguous, or if -// |str| begins with or ends with |s|, then an empty string is inserted. +// Splits |str| into a vector of strings delimited by |s|, placing the results +// in |r|. If several instances of |s| are contiguous, or if |str| begins with +// or ends with |s|, then an empty string is inserted. // // Every substring is trimmed of any leading or trailing white space. // NOTE: |c| must be in BMP (Basic Multilingual Plane) diff --git a/base/string_split_unittest.cc b/base/string_split_unittest.cc index 5d4dafe..a4412e4 100644 --- a/base/string_split_unittest.cc +++ b/base/string_split_unittest.cc @@ -267,7 +267,6 @@ TEST(StringSplitTest, StringSplitDontTrim) { SplitStringDontTrim(" ", '*', &r); ASSERT_EQ(1U, r.size()); EXPECT_EQ(r[0], " "); - r.clear(); SplitStringDontTrim("\t \ta\t ", '\t', &r); ASSERT_EQ(4U, r.size()); @@ -275,13 +274,11 @@ TEST(StringSplitTest, StringSplitDontTrim) { EXPECT_EQ(r[1], " "); EXPECT_EQ(r[2], "a"); EXPECT_EQ(r[3], " "); - r.clear(); SplitStringDontTrim("\ta\t\nb\tcc", '\n', &r); ASSERT_EQ(2U, r.size()); EXPECT_EQ(r[0], "\ta\t"); EXPECT_EQ(r[1], "b\tcc"); - r.clear(); } TEST(StringSplitTest, SplitStringAlongWhitespace) { diff --git a/net/ftp/ftp_directory_listing_parser_vms.cc b/net/ftp/ftp_directory_listing_parser_vms.cc index 9a8a2f7..923f25e 100644 --- a/net/ftp/ftp_directory_listing_parser_vms.cc +++ b/net/ftp/ftp_directory_listing_parser_vms.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -217,7 +217,6 @@ bool ParseFtpDirectoryListingVms( return false; // Join the current and next line and split them into columns. - columns.clear(); base::SplitString( CollapseWhitespace(lines[i] + ASCIIToUTF16(" ") + lines[i + 1], false), diff --git a/webkit/plugins/npapi/plugin_list_win.cc b/webkit/plugins/npapi/plugin_list_win.cc index 3a723138..a9b7193 100644 --- a/webkit/plugins/npapi/plugin_list_win.cc +++ b/webkit/plugins/npapi/plugin_list_win.cc @@ -317,8 +317,6 @@ bool IsNewerVersion(const std::wstring& a, const std::wstring& b) { base::SplitString(a, ',', &a_ver); base::SplitString(b, ',', &b_ver); if (a_ver.size() == 1 && b_ver.size() == 1) { - a_ver.clear(); - b_ver.clear(); base::SplitString(a, '.', &a_ver); base::SplitString(b, '.', &b_ver); } |