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

Side by Side Diff: net/tools/flip_server/split.cc

Issue 6602049: Pure pedantry: Replace all ".size() == 0" with ".empty()". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/tools/flip_server/split.h" 5 #include "net/tools/flip_server/split.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/string_piece.h" 11 #include "base/string_piece.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 // Yea, this could be done with less code duplication using 15 // Yea, this could be done with less code duplication using
16 // template magic, I know. 16 // template magic, I know.
17 void SplitStringPieceToVector(const base::StringPiece& full, 17 void SplitStringPieceToVector(const base::StringPiece& full,
18 const char* delim, 18 const char* delim,
19 std::vector<base::StringPiece>* vec, 19 std::vector<base::StringPiece>* vec,
20 bool omit_empty_strings) { 20 bool omit_empty_strings) {
21 vec->clear(); 21 vec->clear();
22 if (full.size() == 0 || delim[0] == '\0') 22 if (full.empty() || delim[0] == '\0')
23 return; 23 return;
24 24
25 if (delim[1] == '\0') { 25 if (delim[1] == '\0') {
26 base::StringPiece::const_iterator s = full.begin(); 26 base::StringPiece::const_iterator s = full.begin();
27 base::StringPiece::const_iterator e = s; 27 base::StringPiece::const_iterator e = s;
28 for (;e != full.end(); ++e) { 28 for (;e != full.end(); ++e) {
29 if (*e == delim[0]) { 29 if (*e == delim[0]) {
30 if (e != s || !omit_empty_strings) { 30 if (e != s || !omit_empty_strings) {
31 vec->push_back(base::StringPiece(s, e - s)); 31 vec->push_back(base::StringPiece(s, e - s));
32 } 32 }
(...skipping 30 matching lines...) Expand all
63 --e; 63 --e;
64 if (e != s || !omit_empty_strings) { 64 if (e != s || !omit_empty_strings) {
65 vec->push_back(base::StringPiece(s, e - s)); 65 vec->push_back(base::StringPiece(s, e - s));
66 } 66 }
67 } 67 }
68 } 68 }
69 } 69 }
70 70
71 } // namespace net 71 } // namespace net
72 72
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698