summaryrefslogtreecommitdiffstats
path: root/base/string_split.cc
diff options
context:
space:
mode:
authordpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-31 00:44:24 +0000
committerdpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-31 00:44:24 +0000
commita8aa85beefc6146c3881fb41e14a60cfff8b9710 (patch)
treea2ca5835e32c0463489c3a2663616e9e771dfa0f /base/string_split.cc
parent563fb5fc1b451d356fcf5e5ced3591b7181d3874 (diff)
downloadchromium_src-a8aa85beefc6146c3881fb41e14a60cfff8b9710.zip
chromium_src-a8aa85beefc6146c3881fb41e14a60cfff8b9710.tar.gz
chromium_src-a8aa85beefc6146c3881fb41e14a60cfff8b9710.tar.bz2
Revert r12998 - it broke some media/mime-related layout tests.
TBR=pkasting@chromium.org, scherkus@chromium.org Review URL: https://chromiumcodereview.appspot.com/9950039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130011 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_split.cc')
-rw-r--r--base/string_split.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/base/string_split.cc b/base/string_split.cc
index ea694d5..cdf708b 100644
--- a/base/string_split.cc
+++ b/base/string_split.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -17,16 +17,19 @@ static void SplitStringT(const STR& str,
bool trim_whitespace,
std::vector<STR>* r) {
size_t last = 0;
+ size_t i;
size_t c = str.size();
- for (size_t i = 0; i <= c; ++i) {
+ for (i = 0; i <= c; ++i) {
if (i == c || str[i] == s) {
- STR tmp(str, last, i - last);
- if (trim_whitespace)
- TrimWhitespace(tmp, TRIM_ALL, &tmp);
- // Avoid converting an empty or all-whitespace source string into a vector
- // of one empty string.
- if (i != c || !r->empty() || !tmp.empty())
+ size_t len = i - last;
+ STR tmp = str.substr(last, len);
+ if (trim_whitespace) {
+ STR t_tmp;
+ TrimWhitespace(tmp, TRIM_ALL, &t_tmp);
+ r->push_back(t_tmp);
+ } else {
r->push_back(tmp);
+ }
last = i + 1;
}
}