OLD | NEW |
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 Loading... |
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 |
OLD | NEW |