diff --git a/DEPENDENCIES b/DEPENDENCIES index 7632f321..e10c9644 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,6 +1,6 @@ vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4 noa https://github.com/sourcemeta/noa caad2e1ceedf9fd1a18686a6a6d1e2b9757ead75 -jsontoolkit https://github.com/sourcemeta/jsontoolkit a64204f6f69b12021bd1802143f61244f5ea9619 +jsontoolkit https://github.com/sourcemeta/jsontoolkit 117a478711f0aaec0e77a6bee3af0c5030340bb7 googletest https://github.com/google/googletest a7f443b80b105f940225332ed3c31f2790092f47 googlebenchmark https://github.com/google/benchmark 378fe693a1ef51500db21b11ff05a8018c5f0e55 jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite c2badb1298a8698f86dadf1aea7b44b3a894e5ac diff --git a/vendor/jsontoolkit/src/json/include/sourcemeta/jsontoolkit/json_object.h b/vendor/jsontoolkit/src/json/include/sourcemeta/jsontoolkit/json_object.h index b9d2b774..6c376392 100644 --- a/vendor/jsontoolkit/src/json/include/sourcemeta/jsontoolkit/json_object.h +++ b/vendor/jsontoolkit/src/json/include/sourcemeta/jsontoolkit/json_object.h @@ -8,6 +8,22 @@ #include // std::map #else #include // std::unordered_map + +// This hash function is specifically designed to be constant +// with regards to string length, and to exploit the fact that +// most JSON objects don't have a lot of entries, so hash collision +// is not as common +namespace sourcemeta::jsontoolkit { +template struct ObjectKeyHash { + inline auto operator()(const T &value) const noexcept -> std::size_t { + return value.empty() + ? 0 + : value.size() + static_cast(value.front()) + + static_cast(value.back()); + } +}; +} // namespace sourcemeta::jsontoolkit + #endif namespace sourcemeta::jsontoolkit { @@ -23,7 +39,7 @@ template class JSONObject { #if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 12) std::map, #else - std::unordered_map, std::equal_to, + std::unordered_map, std::equal_to, #endif typename Value::template Allocator< std::pair>>;