Skip to content

Commit

Permalink
perf: Fewer JSON pointer lookups
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Jan 22, 2025
1 parent e61c9f8 commit 5773229
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/jsonschema-referencing/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,8 @@ fn collect_external_resources(
{
continue;
}
// Handle local references separately as they may have nested references to external resources
if reference.starts_with('#') {
if reference == "#" {
continue;
}
if let Some(referenced) = pointer(contents, reference.trim_start_matches('#')) {
collect_external_resources(base, referenced, collected, seen)?;
}

if reference == "#" {
continue;
}

Expand All @@ -480,6 +474,14 @@ fn collect_external_resources(
return Ok(());
}

// Handle local references separately as they may have nested references to external resources
if reference.starts_with('#') {
if let Some(referenced) = pointer(contents, reference.trim_start_matches('#')) {
collect_external_resources(base, referenced, collected, seen)?;
}
continue;
}

let resolved = if base.has_fragment() {
let mut base_without_fragment = base.clone();
base_without_fragment.set_fragment(None);
Expand Down

0 comments on commit 5773229

Please sign in to comment.