Bug 924012 - Provide a HashString version for char16_t if needed; r=Waldo
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 15 Oct 2013 11:54:08 -0400
changeset 150777 9b752936ade2f76563ad32a9337e062b490f55df
parent 150776 12e0095aeef9e6012deecda44b4d32a68e615dd7
child 150778 7d0c0b0b89138f52b2a32c04461314cdf008464d
push id34974
push usereakhgari@mozilla.com
push dateTue, 15 Oct 2013 15:56:52 +0000
treeherdermozilla-inbound@ce463593acc6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs924012
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924012 - Provide a HashString version for char16_t if needed; r=Waldo
mfbt/HashFunctions.h
--- a/mfbt/HashFunctions.h
+++ b/mfbt/HashFunctions.h
@@ -43,16 +43,17 @@
  * in nsHashKeys.h.
  */
 
 #ifndef mozilla_HashFunctions_h
 #define mozilla_HashFunctions_h
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/Char16.h"
 #include "mozilla/Types.h"
 
 #include <stdint.h>
 
 #ifdef __cplusplus
 namespace mozilla {
 
 /**
@@ -321,16 +322,32 @@ HashString(const uint16_t* str)
 
 MOZ_WARN_UNUSED_RESULT
 inline uint32_t
 HashString(const uint16_t* str, size_t length)
 {
   return detail::HashKnownLength(str, length);
 }
 
+#ifdef MOZ_CHAR16_IS_NOT_WCHAR
+MOZ_WARN_UNUSED_RESULT
+inline uint32_t
+HashString(const char16_t* str)
+{
+  return detail::HashUntilZero(str);
+}
+
+MOZ_WARN_UNUSED_RESULT
+inline uint32_t
+HashString(const char16_t* str, size_t length)
+{
+  return detail::HashKnownLength(str, length);
+}
+#endif
+
 /*
  * On Windows, wchar_t (PRUnichar) is not the same as uint16_t, even though it's
  * the same width!
  */
 #ifdef WIN32
 MOZ_WARN_UNUSED_RESULT
 inline uint32_t
 HashString(const wchar_t* str)