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

Side by Side Diff: base/string_piece.cc

Issue 8659047: De-duplicate common code from StringPiece, StringPiece16, and their tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Copied from strings/stringpiece.cc with modifications 4 // Copied from strings/stringpiece.cc with modifications
5 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 10
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 return npos; 203 return npos;
204 } 204 }
205 205
206 StringPiece StringPiece::substr(size_type pos, size_type n) const { 206 StringPiece StringPiece::substr(size_type pos, size_type n) const {
207 if (pos > length_) pos = length_; 207 if (pos > length_) pos = length_;
208 if (n > length_ - pos) n = length_ - pos; 208 if (n > length_ - pos) n = length_ - pos;
209 return StringPiece(ptr_ + pos, n); 209 return StringPiece(ptr_ + pos, n);
210 } 210 }
211 211
212 const StringPiece::size_type StringPiece::npos = size_type(-1);
213
214 } // namespace base 212 } // namespace base
OLDNEW
« base/string_piece.h ('K') | « base/string_piece.h ('k') | base/string_piece_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698