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 /base/string_split.cc | |
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
Diffstat (limited to 'base/string_split.cc')
-rw-r--r-- | base/string_split.cc | 3 |
1 files changed, 3 insertions, 0 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; |