Skip to content

Commit

Permalink
[WIP] Optimise try_at in JSON
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Jan 21, 2025
1 parent d3436cf commit 7abd899
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6
noa https://github.com/sourcemeta/noa dee6c859895baf918fe3ecca22e4e7a262c5d500
noa https://github.com/sourcemeta/noa ee488bdc06f5587dc132012b6aabcdaea98c973e
jsontestsuite https://github.com/nst/JSONTestSuite d64aefb55228d9584d3e5b2433f720ea8fd00c82
jsonschema-2020-12 https://github.com/json-schema-org/json-schema-spec 769daad75a9553562333a8937a187741cb708c72
jsonschema-2019-09 https://github.com/json-schema-org/json-schema-spec 41014ea723120ce70b314d72f863c6929d9f3cfd
Expand Down
6 changes: 2 additions & 4 deletions src/json/json_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,7 @@ JSON::at(const String &key,
[[nodiscard]] auto JSON::try_at(const JSON::String &key) const -> const JSON * {
assert(this->is_object());
const auto &object{this->data_object};
const auto value{object.data.find(key, object.data.hash(key))};
return value == object.data.cend() ? nullptr : &value->second;
return object.data.try_at(key, object.data.hash(key));
}

[[nodiscard]] auto
Expand All @@ -678,8 +677,7 @@ JSON::try_at(const String &key,
-> const JSON * {
assert(this->is_object());
const auto &object{this->data_object};
const auto value{object.data.find(key, hash)};
return value == object.data.cend() ? nullptr : &value->second;
return object.data.try_at(key, hash);
}

[[nodiscard]] auto JSON::defines(const JSON::String &key) const -> bool {
Expand Down
23 changes: 23 additions & 0 deletions vendor/noa/src/flat_map/include/sourcemeta/noa/flat_map.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7abd899

Please sign in to comment.