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

Unified Diff: base/string_split.cc

Issue 9950039: Revert r12998 - it broke some media/mime-related layout tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | « no previous file | base/string_split_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_split.cc
diff --git a/base/string_split.cc b/base/string_split.cc
index ea694d5ab1d423765fab32c146ff9634328706c5..cdf708ba5116dab6dfc0f6a29ad14de3c3513f5f 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;
}
}
« no previous file with comments | « no previous file | base/string_split_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698