mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-01 00:15:51 +00:00
Move MurmurHash to beast
This commit is contained in:
@@ -111,6 +111,7 @@
|
||||
<ClInclude Include="..\..\beast\config\StandardConfig.h" />
|
||||
<ClInclude Include="..\..\beast\Crypto.h" />
|
||||
<ClInclude Include="..\..\beast\crypto\impl\sha2\sha2.h" />
|
||||
<ClInclude Include="..\..\beast\crypto\MurmurHash.h" />
|
||||
<ClInclude Include="..\..\beast\crypto\Sha256.h" />
|
||||
<ClInclude Include="..\..\beast\CStdInt.h" />
|
||||
<ClInclude Include="..\..\beast\FixedArray.h" />
|
||||
@@ -280,7 +281,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Expression.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Interval.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Math.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\MurmurHash.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Random.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Range.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\uint24.h" />
|
||||
@@ -425,6 +425,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\crypto\Crypto.cpp" />
|
||||
<ClCompile Include="..\..\beast\crypto\impl\MurmurHash.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\crypto\impl\Sha256.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -879,12 +885,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\maths\MurmurHash.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\maths\Random.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -683,9 +683,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_sqdb\detail\use_type.h">
|
||||
<Filter>beast_sqdb\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\MurmurHash.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\LexicalCast.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
@@ -1263,6 +1260,9 @@
|
||||
<ClInclude Include="..\..\beast\asio\IPAddressConversion.h">
|
||||
<Filter>beast\asio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\crypto\MurmurHash.h">
|
||||
<Filter>beast\crypto</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
||||
@@ -1565,9 +1565,6 @@
|
||||
<ClCompile Include="..\..\modules\beast_sqdb\source\use_type.cpp">
|
||||
<Filter>beast_sqdb\source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\maths\MurmurHash.cpp">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\LexicalCast.cpp">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClCompile>
|
||||
@@ -1817,6 +1814,9 @@
|
||||
<ClCompile Include="..\..\beast\asio\impl\IPAddressConversion.cpp">
|
||||
<Filter>beast\asio\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\crypto\impl\MurmurHash.cpp">
|
||||
<Filter>beast\crypto\impl</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\TODO.txt">
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef BEAST_CRYPTO_H_INCLUDED
|
||||
#define BEAST_CRYPTO_H_INCLUDED
|
||||
|
||||
#include "crypto/MurmurHash.h"
|
||||
#include "crypto/Sha256.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,4 +19,5 @@
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "impl/MurmurHash.cpp"
|
||||
#include "impl/Sha256.cpp"
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_MURMURHASH_H_INCLUDED
|
||||
#define BEAST_MURMURHASH_H_INCLUDED
|
||||
#ifndef BEAST_CRYPTO_MURMURHASH_H_INCLUDED
|
||||
#define BEAST_CRYPTO_MURMURHASH_H_INCLUDED
|
||||
|
||||
#include "../CStdInt.h"
|
||||
|
||||
// Original source code links in .cpp file
|
||||
|
||||
// This file depends on some Beast declarations and defines
|
||||
|
||||
namespace Murmur
|
||||
{
|
||||
namespace beast {
|
||||
namespace Murmur {
|
||||
|
||||
extern void MurmurHash3_x86_32 (const void* key, int len, uint32 seed, void* out);
|
||||
extern void MurmurHash3_x86_128 (const void* key, int len, uint32 seed, void* out);
|
||||
@@ -77,6 +77,7 @@ inline void Hash (const void* key, int len, uint32 seed, HashType* out)
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,8 +19,12 @@
|
||||
|
||||
// http://code.google.com/p/smhasher/
|
||||
|
||||
namespace Murmur
|
||||
{
|
||||
#include "../MurmurHash.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace beast {
|
||||
namespace Murmur {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Platform-specific functions and macros
|
||||
@@ -485,3 +489,4 @@ void MurmurHash3_x64_128 ( const void* key, const int len,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -195,6 +195,9 @@ public:
|
||||
/** Generates a probably-unique 64-bit hashcode from this string. */
|
||||
int64 hashCode64() const noexcept;
|
||||
|
||||
/** Returns a hash value suitable for use with std::hash. */
|
||||
std::size_t hash() const noexcept;
|
||||
|
||||
/** Returns the number of characters in the string. */
|
||||
int length() const noexcept;
|
||||
|
||||
|
||||
@@ -404,26 +404,42 @@ beast_wchar String::operator[] (int index) const noexcept
|
||||
return text [index];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Type>
|
||||
struct HashGenerator
|
||||
{
|
||||
template <typename CharPointer>
|
||||
static Type calculate (CharPointer t) noexcept
|
||||
{
|
||||
Type result = Type();
|
||||
|
||||
while (! t.isEmpty())
|
||||
result = multiplier * result + t.getAndAdvance();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
enum { multiplier = sizeof (Type) > 4 ? 101 : 31 };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
int String::hashCode() const noexcept
|
||||
{
|
||||
CharPointerType t (text);
|
||||
int result = 0;
|
||||
|
||||
while (! t.isEmpty())
|
||||
result = 31 * result + (int) t.getAndAdvance();
|
||||
|
||||
return result;
|
||||
return detail::HashGenerator<int> ::calculate (text);
|
||||
}
|
||||
|
||||
int64 String::hashCode64() const noexcept
|
||||
{
|
||||
CharPointerType t (text);
|
||||
int64 result = 0;
|
||||
return detail::HashGenerator<int64> ::calculate (text);
|
||||
}
|
||||
|
||||
while (! t.isEmpty())
|
||||
result = 101 * result + t.getAndAdvance();
|
||||
|
||||
return result;
|
||||
std::size_t String::hash() const noexcept
|
||||
{
|
||||
return detail::HashGenerator<std::size_t>::calculate (text);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -156,7 +156,6 @@ namespace beast
|
||||
|
||||
#include "maths/BigInteger.cpp"
|
||||
#include "maths/Expression.cpp"
|
||||
#include "maths/MurmurHash.cpp"
|
||||
#include "maths/Random.cpp"
|
||||
|
||||
#include "memory/MemoryBlock.cpp"
|
||||
|
||||
@@ -187,7 +187,6 @@ class FileOutputStream;
|
||||
#include "logging/Logger.h"
|
||||
#include "maths/Expression.h"
|
||||
#include "maths/Interval.h"
|
||||
#include "maths/MurmurHash.h"
|
||||
#include "memory/OptionalScopedPointer.h"
|
||||
#include "memory/SharedSingleton.h"
|
||||
#include "memory/WeakReference.h"
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
#endif
|
||||
|
||||
#include "../beast_core/beast_core.h"
|
||||
#include "../../beast/crypto/MurmurHash.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace beast
|
||||
{
|
||||
namespace beast {
|
||||
|
||||
# include "math/UnsignedIntegerCalc.h"
|
||||
#include "math/UnsignedInteger.h"
|
||||
|
||||
Reference in New Issue
Block a user