Bug 1480660 - Remove ConstExprHash{UntilZero,String}(). r=froydnj

They were workarounds for bugs in GCC 4.9, which is no longer supported.

--HG--
extra : rebase_source : b793b4643e1e44199afdb8e8b35f930e02664be8
This commit is contained in:
Nicholas Nethercote 2018-08-03 14:47:41 +10:00
parent b0b2b901d0
commit 097b276f5c
2 changed files with 5 additions and 30 deletions

View file

@ -249,29 +249,16 @@ HashGeneric(Args... aArgs)
namespace detail {
template<typename T>
HashNumber
constexpr HashNumber
HashUntilZero(const T* aStr)
{
HashNumber hash = 0;
for (T c; (c = *aStr); aStr++) {
for (; T c = *aStr; aStr++) {
hash = AddToHash(hash, c);
}
return hash;
}
// This is a `constexpr` alternative to HashUntilZero(const T*). It should
// only be used for compile-time computation because it uses recursion.
// XXX: once support for GCC 4.9 is dropped, this function should be removed
// and HashUntilZero(const T*) should be made `constexpr`.
template<typename T>
constexpr HashNumber
ConstExprHashUntilZero(const T* aStr, HashNumber aHash)
{
return !*aStr
? aHash
: ConstExprHashUntilZero(aStr + 1, AddToHash(aHash, *aStr));
}
template<typename T>
HashNumber
HashKnownLength(const T* aStr, size_t aLength)
@ -310,25 +297,13 @@ HashString(const unsigned char* aStr, size_t aLength)
return detail::HashKnownLength(aStr, aLength);
}
MOZ_MUST_USE inline HashNumber
HashString(const char16_t* aStr)
{
return detail::HashUntilZero(aStr);
}
// This is a `constexpr` alternative to HashString(const char16_t*). It should
// only be used for compile-time computation because it uses recursion.
//
// You may need to use the
// MOZ_{PUSH,POP}_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING macros if you use
// this function. See the comment on those macros' definitions for more detail.
//
// XXX: once support for GCC 4.9 is dropped, this function should be removed
// and HashString(const char16_t*) should be made `constexpr`.
MOZ_MUST_USE constexpr HashNumber
ConstExprHashString(const char16_t* aStr)
HashString(const char16_t* aStr)
{
return detail::ConstExprHashUntilZero(aStr, 0);
return detail::HashUntilZero(aStr);
}
MOZ_MUST_USE inline HashNumber

View file

@ -107,7 +107,7 @@ protected:
constexpr nsAtom(const char16_t* aStr, uint32_t aLength)
: mLength(aLength)
, mKind(static_cast<uint32_t>(nsAtom::AtomKind::Static))
, mHash(mozilla::ConstExprHashString(aStr))
, mHash(mozilla::HashString(aStr))
{}
// Used by nsDynamicAtom.