Skip to content

Commit

Permalink
perf: Avoid re-computing resource id
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
  • Loading branch information
Stranger6667 committed Feb 5, 2025
1 parent 42368f5 commit 802fcb6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/jsonschema-referencing/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ fn process_resources(

// Process current queue and collect references to external resources
while let Some((mut base, resource)) = queue.pop_front() {
let mut has_id = false;
if let Some(id) = resource.id() {
has_id = true;
base = resolution_cache.resolve_against(&base.borrow(), id)?;
}

Expand All @@ -463,7 +465,7 @@ fn process_resources(
let subresource = InnerResourcePtr::new(contents, resource.draft());
queue.push_back((base.clone(), subresource));
}
if resource.id().is_some() {
if has_id {
resources.insert(base, resource.clone());
}
}
Expand Down

0 comments on commit 802fcb6

Please # to comment.