1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-25 13:41:56 +03:00

hash function without allocation

This commit is contained in:
Niels Lohmann
2020-07-14 14:31:19 +02:00
parent 1a521cbd36
commit 5b229f4cce
3 changed files with 191 additions and 6 deletions

View File

@ -51,6 +51,7 @@ SOFTWARE.
#include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp>
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/hash.hpp>
#include <nlohmann/detail/input/binary_reader.hpp>
#include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/input/lexer.hpp>
@ -8698,9 +8699,7 @@ struct hash<nlohmann::json>
*/
std::size_t operator()(const nlohmann::json& j) const
{
// a naive hashing via the string representation
const auto& h = hash<nlohmann::json::string_t>();
return h(j.dump());
return nlohmann::detail::hash(j);
}
};