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

Unified Diff: core/fxcrt/include/fx_string.h

Issue 2341683005: Add string pools to save storage. (Closed)
Patch Set: fix compile Created 4 years, 3 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
Index: core/fxcrt/include/fx_string.h
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index c1bd82dd7470367cd812cae61215cdedfe7f503a..82f07259f539db53a9cb1328883aba4737f09b9c 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -8,7 +8,9 @@
#define CORE_FXCRT_INCLUDE_FX_STRING_H_
#include <stdint.h> // For intptr_t.
+
#include <algorithm>
+#include <functional>
#include "core/fxcrt/cfx_string_c_template.h"
#include "core/fxcrt/cfx_string_data_template.h"
@@ -170,7 +172,9 @@ class CFX_ByteString {
void Concat(const FX_CHAR* lpszSrcData, FX_STRSIZE nSrcLen);
CFX_RetainPtr<StringData> m_pData;
+
friend class fxcrt_ByteStringConcat_Test;
+ friend class fxcrt_ByteStringPool_Test;
};
inline bool operator==(const char* lhs, const CFX_ByteString& rhs) {
@@ -365,7 +369,9 @@ class CFX_WideString {
void Concat(const FX_WCHAR* lpszSrcData, FX_STRSIZE nSrcLen);
CFX_RetainPtr<StringData> m_pData;
+
friend class fxcrt_WideStringConcatInPlace_Test;
+ friend class fxcrt_WideStringPool_Test;
};
inline CFX_WideString operator+(const CFX_WideStringC& str1,
@@ -440,4 +446,28 @@ inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) {
bool FX_atonum(const CFX_ByteStringC& str, void* pData);
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
+uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase);
+uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase);
+
+namespace std {
dsinclair 2016/09/15 20:23:26 Are we allowed to put things into namespace std?
Tom Sepez 2016/09/15 20:51:24 See https://cs.chromium.org/chromium/src/base/opti
+
+template <>
+struct hash<CFX_ByteString> {
+ std::size_t operator()(const CFX_ByteString& str) const {
+ return FX_HashCode_GetA(str.AsStringC(), false);
+ }
+};
+
+template <>
+struct hash<CFX_WideString> {
+ std::size_t operator()(const CFX_WideString& str) const {
+ return FX_HashCode_GetW(str.AsStringC(), false);
+ }
+};
+
+} // namespace std
+
+extern template struct std::hash<CFX_ByteString>;
+extern template struct std::hash<CFX_WideString>;
+
#endif // CORE_FXCRT_INCLUDE_FX_STRING_H_
« core/fxcrt/cfx_string_pool_template_unittest.cpp ('K') | « core/fxcrt/include/fx_ext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698