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

Unified Diff: net/tools/balsa/string_piece_utils.h

Issue 312003002: Port net/tools/balsa to non-Linux platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compiler warnings Created 6 years, 6 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
« net/tools/balsa/balsa_frame.cc ('K') | « net/tools/balsa/balsa_headers.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/balsa/string_piece_utils.h
diff --git a/net/tools/balsa/string_piece_utils.h b/net/tools/balsa/string_piece_utils.h
index eb0eaf365c83c03afb82b0a419be1094649dfc02..12fc69be85fca9e2ccda824d50774bada11dc587 100644
--- a/net/tools/balsa/string_piece_utils.h
+++ b/net/tools/balsa/string_piece_utils.h
@@ -12,6 +12,34 @@
namespace net {
+#if defined(COMPILER_MSVC)
+struct StringPieceCaseCompare {
+ static const size_t bucket_size = 4;
+
+ size_t operator()(const base::StringPiece& sp) const {
+ // based on __stl_string_hash in http://www.sgi.com/tech/stl/string
+ size_t hash_val = 0;
+ for (base::StringPiece::const_iterator it = sp.begin();
+ it != sp.end(); ++it) {
+ hash_val = 5 * hash_val + tolower(*it);
+ }
+ return hash_val;
+ }
+
+ bool operator()(const base::StringPiece& sp1,
+ const base::StringPiece& sp2) const {
+ size_t len1 = sp1.length();
+ size_t len2 = sp2.length();
+ bool sp1_shorter = len1 < len2;
+ size_t len = sp1_shorter ? len1 : len2;
+ int rv = _memicmp(sp1.data(), sp2.data(), len);
+ if (rv == 0) {
+ return sp1_shorter;
+ }
+ return rv < 0;
+ }
+};
+#else // COMPILER_MSVC
struct StringPieceCaseHash {
size_t operator()(const base::StringPiece& sp) const {
// based on __stl_string_hash in http://www.sgi.com/tech/stl/string
@@ -23,6 +51,7 @@ struct StringPieceCaseHash {
return hash_val;
}
};
+#endif // COMPILER_MSVC
struct StringPieceUtils {
static bool EqualIgnoreCase(const base::StringPiece& piece1,
« net/tools/balsa/balsa_frame.cc ('K') | « net/tools/balsa/balsa_headers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698