moxml 0.5.58 → 0.5.59

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: 03fd3940f1334b3f417e4847f35e87497581404372209de4426819a8acc6d363
4
- data.tar.gz: 805f6966495456ff6e36c4f1be3df9fcbbf1c89cfcf2ddc6a4153c37e1bcec71
3
+ metadata.gz: '0093cdce010f7f3dbc901b0c202b524f6df10b821fd8ed07e290688c22957ab1'
4
+ data.tar.gz: bffcd7f1fc07278194510a2a1cc427bf19917028643b210380bd3f37f831f22d
5
5
  SHA512:
6
- metadata.gz: 872ba59e6f8b72779d2ea43c8af201052a69be9d75ad1add3fa2618bc58e81cee0503ce352d06c8b46c64cc6340859006b36afeadef4302f29c81e2760285baa
7
- data.tar.gz: 01eed98fc6ac76efb35d2456c9af57487bbdddf13092a09b0667d11e6e2d48a1905865046aab6a59ca8a89523fc4337a705c1b1cf95d98342d56cb4494c0d91e
6
+ metadata.gz: 47fab72bf502121e85e39358ffe615618af913cf5a3535c014ad2a614d0c910102b0c763c31a3d0ab4f0032bc2af407ce11da511fed05725d1fe0e2e53591ccf
7
+ data.tar.gz: dca3fd95a60a848a34cc880b5173a8f98b0f24f17b7be71e5a7eff00f92add6c807b44fa7525e70d7488f13ba8e037bf5f8b9e84fb26d9c7ddf9c02cc7ed8f10
@@ -222,10 +222,30 @@ module Moxml
222
222
  ELEMENT_CONTRACT_READ =
223
223
  ::Moxml::ElementBehavior.instance_method(:[])
224
224
 
225
+ # Marker presence is a DOCUMENT fact, but the wrapper
226
+ # memo re-derives it per node (the per-read machinery
227
+ # was ~a quarter of the consumer walk). Doc-level
228
+ # WeakMap, generation-stamped into one Integer
229
+ # (immediates make safe weak values): one C document
230
+ # read plus one map hit per bare read. Entries die
231
+ # with their documents; a stale generation re-derives.
232
+ ENTITY_DOC_MEMO = ::ObjectSpace::WeakMap.new
233
+
234
+ def doc_entity_bearing?
235
+ doc = NN_DOCUMENT.bind_call(self)
236
+ memo = ENTITY_DOC_MEMO[doc]
237
+ gen = ::Moxml::Adapter::Leptris.serialize_generation
238
+ return memo.allbits?(1) if memo && (memo >> 1) == gen
239
+
240
+ bearing = ::Moxml::Adapter::Leptris.entity_bearing?(self)
241
+ ENTITY_DOC_MEMO[doc] = (gen << 1) | (bearing ? 1 : 0)
242
+ bearing
243
+ end
244
+
225
245
  def [](key)
226
246
  if key.is_a?(String) && !key.include?(":")
227
247
  value = NN_ATTRIBUTE.bind_call(self, key)
228
- return value unless value.is_a?(String) && entity_bearing?
248
+ return value unless value.is_a?(String) && doc_entity_bearing?
229
249
 
230
250
  return ::Moxml::Adapter::Leptris.restore_entities(value)
231
251
  end
@@ -235,7 +255,7 @@ module Moxml
235
255
 
236
256
  def text
237
257
  value = NN_CONTENT.bind_call(self)
238
- value.is_a?(String) && entity_bearing? ? ::Moxml::Adapter::Leptris.restore_entities(value) : value
258
+ value.is_a?(String) && doc_entity_bearing? ? ::Moxml::Adapter::Leptris.restore_entities(value) : value
239
259
  end
240
260
  end
241
261
  ELEMENT.include(Reads)
data/lib/moxml/node.rb CHANGED
@@ -164,30 +164,18 @@ module Moxml
164
164
  # entity-marker flag flips at parse and entity-reference mint,
165
165
  # both adapter-level, and the generation bump is the invalidation
166
166
  # signal. Adapters with static answers (base class) never bump.
167
+ # The adapter resolves the owning document itself (doc_for is a
168
+ # single C read on the native layer); wrappers no longer climb.
167
169
  def entity_bearing?
168
170
  gen = adapter.serialize_generation
169
171
  if @entity_bearing_gen == gen
170
172
  @entity_bearing
171
173
  else
172
174
  @entity_bearing_gen = gen
173
- @entity_bearing = adapter.entity_bearing?(@native, document_native_for_markers)
175
+ @entity_bearing = adapter.entity_bearing?(@native)
174
176
  end
175
177
  end
176
178
 
177
- # Binding document through the wrapper parent chain — pure Ruby
178
- # attr reads; the native-layer fallback climbs C parents per
179
- # call (the doc_for walk was the largest wrapper-layer cost on
180
- # the consumer pipeline after the native adoption).
181
- def document_native_for_markers
182
- node = self
183
- while node
184
- return node.native if node.document?
185
-
186
- node = node.parent_node
187
- end
188
- nil
189
- end
190
-
191
179
  def xpath(expression, namespaces = {})
192
180
  result = adapter.xpath(@native, expression, namespaces)
193
181
  # Adapter contract: Array<native> | LazyNodeSet | scalar.
data/lib/moxml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.5.58"
4
+ VERSION = "0.5.59"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.58
4
+ version: 0.5.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.