summaryrefslogtreecommitdiffstats
path: root/base/string_piece.h
diff options
context:
space:
mode:
authorsuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 02:40:46 +0000
committersuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 02:40:46 +0000
commit39a749c1cc998edcd66edfc3ffc9004710825f46 (patch)
tree370b1a18564e743cfbfc16beb4d0053437064486 /base/string_piece.h
parent911696b92b1b5a666e59433b8b64303a2f4eae62 (diff)
downloadchromium_src-39a749c1cc998edcd66edfc3ffc9004710825f46.zip
chromium_src-39a749c1cc998edcd66edfc3ffc9004710825f46.tar.gz
chromium_src-39a749c1cc998edcd66edfc3ffc9004710825f46.tar.bz2
Change UTF8ToUTF16 to accept const StringPiece&.
BUG=70936 TEST=All unit tests should pass. Review URL: http://codereview.chromium.org/6317016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_piece.h')
-rw-r--r--base/string_piece.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/base/string_piece.h b/base/string_piece.h
index 80c6cab..64326e1 100644
--- a/base/string_piece.h
+++ b/base/string_piece.h
@@ -19,8 +19,6 @@
#define BASE_STRING_PIECE_H_
#pragma once
-#include <algorithm>
-#include <iosfwd>
#include <string>
#include "base/basictypes.h"
@@ -93,7 +91,8 @@ class StringPiece {
}
int compare(const StringPiece& x) const {
- int r = wordmemcmp(ptr_, x.ptr_, std::min(length_, x.length_));
+ int r = wordmemcmp(
+ ptr_, x.ptr_, (length_ < x.length_ ? length_ : x.length_));
if (r == 0) {
if (length_ < x.length_) r = -1;
else if (length_ > x.length_) r = +1;
@@ -171,8 +170,8 @@ inline bool operator!=(const StringPiece& x, const StringPiece& y) {
}
inline bool operator<(const StringPiece& x, const StringPiece& y) {
- const int r = StringPiece::wordmemcmp(x.data(), y.data(),
- std::min(x.size(), y.size()));
+ const int r = StringPiece::wordmemcmp(
+ x.data(), y.data(), (x.size() < y.size() ? x.size() : y.size()));
return ((r < 0) || ((r == 0) && (x.size() < y.size())));
}
@@ -188,9 +187,6 @@ inline bool operator>=(const StringPiece& x, const StringPiece& y) {
return !(x < y);
}
-// allow StringPiece to be logged (needed for unit testing).
-extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece);
-
} // namespace base
#endif // BASE_STRING_PIECE_H_