diff options
| author | Josh Ferrell <josh@vector35.com> | 2022-11-25 17:24:35 -0500 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2022-11-28 13:45:52 -0500 |
| commit | 29d42a3910abe6051992820f9c3fa08c7b49217f (patch) | |
| tree | 1982f4f73d3e981241d4905d435d6e4faf60374b | |
| parent | f36ea5dc522db920a7c182a3b79cd2a57e52b386 (diff) | |
Faster hashing of rapidjson values
| -rw-r--r-- | rapidjsonwrapper.h | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/rapidjsonwrapper.h b/rapidjsonwrapper.h index dfc1fde9..e12465d6 100644 --- a/rapidjsonwrapper.h +++ b/rapidjsonwrapper.h @@ -106,29 +106,27 @@ static inline uint64_t HashRapidValue(const rapidjson::Value& val) } case rapidjson::kNumberType: { - size_t h; - if (val.IsDouble()) + if (val.IsInt64()) { - const double dVal = val.GetDouble(); - h = HashBytes(&dVal, sizeof(dVal)); + return combine(type, static_cast<size_t>(val.GetInt64())); } - else if (val.IsInt()) + else if (val.IsUint64()) { - h = static_cast<size_t>(val.GetInt()); + return combine(type, val.GetUint64()); } - else if (val.IsInt64()) + else if (val.IsUint()) { - h = static_cast<size_t>(val.GetUint64()); + return combine(type, static_cast<size_t>(val.GetUint())); } - else if (val.IsUint()) + else if (val.IsInt()) { - h = static_cast<size_t>(val.GetUint()); + return combine(type, static_cast<size_t>(val.GetInt())); } else { - h = val.GetUint64(); + const double dVal = val.GetDouble(); + return combine(type, HashBytes(&dVal, sizeof(dVal))); } - return combine(type, h); } default: |
