leptris 1.9.366.1 → 1.9.366.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97ab0ffc1ab21b11d43593a97f8d91f75f49028460d68d5f0fdf7dbe14f697f7
4
- data.tar.gz: 3badee92d7d7744c93da9434badb3401e7b4e5b4f61acc3e984029ed16dcf903
3
+ metadata.gz: bdbc55946efddecae9ca22ce9afb09b6e3b22adcb9904f9a0d21b5d009f0fabf
4
+ data.tar.gz: 321b6aa17d26eb61638e7e6108b3ef32edfefc9074341261cdb7572f501e762b
5
5
  SHA512:
6
- metadata.gz: 9222fe57cebd087fe04c892116bd771266c1671039d2c8a6bf7fd0846b746210766adc8db5c7824289e9cd7e48cb17effb3ec37a2505732f29da52068ccf7fe9
7
- data.tar.gz: 6f9fc5fc3e204d9112e9f49bdd829b3a0c11360135a8037f471753c01e414e688a6b94ee35f2bf89113898d0f702119f1f076e4716dac17fa2da9077bbbdd4b5
6
+ metadata.gz: a6351c134abf1fcbf925f76ac950ea8f23f252aa01edb7231a1510c201f5bc363c456f0a7560302304b5aec01a596a07a0a56c6140c0320bad6c51d3ca711e4d
7
+ data.tar.gz: 39e95a64f54eed408f0dd3fb1c640b9cd4a087f08e5b97bdeb367e02bb28a7947e072fd9b8becaad9ff1798807744e96e710278a33ad6e822602733f67bfd9f9
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.366.1"
4
+ VERSION = "1.9.366.2"
5
5
  end
@@ -126,7 +126,7 @@ class Leptris::XML::Descriptor
126
126
  "descriptor ABI v#{abi} != binding v#{Leptris::XML::FFI::PLAN_ABI_VERSION}"
127
127
  end
128
128
  plans = []
129
- root_index = flatten_plan(tree, plans)
129
+ root_index = flatten_plan(tree, plans, {})
130
130
  spec, plans_pointer, anchors = pack_plans(plans)
131
131
  spec[:abi_version] = abi
132
132
  spec[:plan_count] = plans.size
@@ -143,13 +143,32 @@ class Leptris::XML::Descriptor
143
143
  # Flattens the nested hash tree into the engine's flat plans
144
144
  # array (child rows reference plans by index). Returns the root
145
145
  # plan's index — always 0 for a single root.
146
- def self.flatten_plan(tree, plans)
147
- tree = tree.dup
148
- plans << tree
146
+ #
147
+ # Identity-memoized (leptris#1743): lutaml-model's PlanCompiler
148
+ # (0.8.107+) feeds recursive content models as a DAG — the SAME
149
+ # plan Hash reachable from many parents. Without the memo each
150
+ # shared subtree re-flattened once per path (2^depth visits: the
151
+ # STS runaway — 28+ CPU-min, 14 GB RSS) and the duplicated index
152
+ # graph even mis-walked. Memoize on the ARGUMENT's identity
153
+ # (object_id, read before the dup) so each unique plan object is
154
+ # flattened once and shared rows reference one index.
155
+ def self.flatten_plan(tree, plans, memo = {})
156
+ key = tree.object_id
157
+ hit = memo[key]
158
+ return hit if hit
159
+
160
+ raise Leptris::XML::Error,
161
+ "plan tree contains a cycle at #{tree[:name].inspect} — " "the plan graph must be a DAG" if hit == false
162
+
163
+ memo[key] = false # in-progress; a finished entry is an Integer index
164
+ duped = tree.dup
165
+ plans << duped
149
166
  tree_index = plans.size - 1
150
- tree[:children] = (tree[:children] || []).map do |row|
167
+ memo[key] = tree_index
168
+ duped[:children] = (duped[:children] || []).map do |row|
151
169
  if row[:kind] == :nested
152
- row.merge(child_plan_index: flatten_plan(row.fetch(:plan), plans))
170
+ row.merge(child_plan_index: flatten_plan(row.fetch(:plan), plans,
171
+ memo))
153
172
  else
154
173
  row
155
174
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.366.1
4
+ version: 1.9.366.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.