Skip to content

Commit

Permalink
MetaschemaNode#jsi_indicated_schemas memoized
Browse files Browse the repository at this point in the history
  • Loading branch information
notEthan committed Jul 16, 2023
1 parent e66872e commit e684e77
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/jsi/metaschema_node.rb
Expand Up @@ -67,13 +67,14 @@ def initialize(
jsi_ptr: root_schema_ptr,
jsi_schema_base_uri: nil, # supplying jsi_schema_base_uri on root bootstrap schema is not supported
)
@bootstrap_indicated_schemas = jsi_ptr.tokens.inject(SchemaSet[root_bootstrap_schema]) do |bootstrap_indicated_schemas, tok|
our_bootstrap_indicated_schemas = jsi_ptr.tokens.inject(SchemaSet[root_bootstrap_schema]) do |bootstrap_indicated_schemas, tok|
bootstrap_schemas = bootstrap_indicated_schemas.inplace_applicator_schemas(instance_for_schemas)
child_indicated_schemas = bootstrap_schemas.child_applicator_schemas(tok, instance_for_schemas)
instance_for_schemas = instance_for_schemas[tok]
child_indicated_schemas
end
our_bootstrap_schemas = @bootstrap_indicated_schemas.inplace_applicator_schemas(instance_for_schemas)
@indicated_schemas_map = jsi_memomap { bootstrap_schemas_to_msn(our_bootstrap_indicated_schemas) }
our_bootstrap_schemas = our_bootstrap_indicated_schemas.inplace_applicator_schemas(instance_for_schemas)

our_bootstrap_schemas.each do |bootstrap_schema|
if bootstrap_schema.jsi_ptr == metaschema_root_ptr
Expand Down Expand Up @@ -140,7 +141,7 @@ def initialize(
# See {Base#jsi_indicated_schemas}
# @return [JSI::SchemaSet]
def jsi_indicated_schemas
bootstrap_schemas_to_msn(@bootstrap_indicated_schemas)
@indicated_schemas_map[]
end

# see {Base#jsi_child}
Expand Down

0 comments on commit e684e77

Please sign in to comment.