moxml 0.5.60 → 0.5.61

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: 70fbb27b6a314c772f06699958b27c017a5033c33a62f84ff98d15c3c8a866a0
4
- data.tar.gz: 4222b8eb5f128d74bc55a3284596f11bc975684eae28ff3f0cb8fe56bb2a4899
3
+ metadata.gz: 432ffb6c040c2b5689552a050b01835b792cde27ddc816981fd186fd83b9df7d
4
+ data.tar.gz: 917f7712e1799209f6d1c3f832fb5a3de492da5e570959a9d8bf2a8b4902d537
5
5
  SHA512:
6
- metadata.gz: '08307faaef4bfdfbda347f2f860f71f4aedabfc1b30bf81bcdfe876296ee68df6138e42efcf92c04cb94f3696a8ff33b038ce40bf826ad87491a1ee07364e2c3'
7
- data.tar.gz: 1f084671c8983ed53172652e6322670b09550758b76378b30905bf1c1c30e7cc531d9fdd46edc3ecd7d9bf2ffa6cbd23e79a989a9d0237eae020191265c29641
6
+ metadata.gz: b6f0a69c52df888bf9afbc2706e755d9844d8d65247720d887cc6fb34c8d855964f278d798b947bfb028ce58f32253ff6ed92101fcc2cf45fe28695170c23405
7
+ data.tar.gz: 90b841bd8eb58119a38dce5333a53f9b37abc70755e69a887c52ab4565d1101727a2dcc40903a4671b92a10d4ba1bd67ab712ac97d37bdd04861359dd4b09bba
@@ -213,49 +213,84 @@ module Moxml
213
213
  processing_instruction: PROCESSING_INSTRUCTION,
214
214
  }.freeze
215
215
 
216
- module Reads
217
- # The C methods sit BELOW the contract modules in the
218
- # ancestry (NativeNode is the superclass), so super
219
- # from here would run the contract implementation and
220
- # ADD frames. bind_call reaches the C surface
221
- # directly; prefixed names take the contract path.
222
- ELEMENT_CONTRACT_READ =
223
- ::Moxml::ElementBehavior.instance_method(:[])
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
216
+ # Hot-read face selection: bindings >= 1.9.194.1 carry
217
+ # unshadowed aliases (attr_read/text_read) that plain
218
+ # dispatch reaches at method-cache cost beats
219
+ # UnboundMethod#bind_call (~86ns) on every bare read.
220
+ ELEMENT_CONTRACT_READ =
221
+ ::Moxml::ElementBehavior.instance_method(:[])
222
+
223
+ NATIVE_HOT_ALIASES =
224
+ Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.194.1")
225
+
226
+ # Doc-level entity-marker memo shared by both hot-read
227
+ # faces (one WeakMap, generation-stamped Integer values).
228
+ ENTITY_DOC_MEMO = ::ObjectSpace::WeakMap.new
229
+
230
+ if NATIVE_HOT_ALIASES
231
+ module Reads
232
+ # Marker presence is a DOCUMENT fact, but the wrapper
233
+ # memo re-derives it per node (the per-read machinery
234
+ # was ~a quarter of the consumer walk). Doc-level
235
+ # WeakMap, generation-stamped into one Integer
236
+ # (immediates make safe weak values): one C document
237
+ # read plus one map hit per bare read. Entries die
238
+ # with their documents; a stale generation re-derives.
239
+ def doc_entity_bearing?
240
+ doc = NN_DOCUMENT.bind_call(self)
241
+ memo = ENTITY_DOC_MEMO[doc]
242
+ gen = ::Moxml::Adapter::Leptris.serialize_generation
243
+ return memo.allbits?(1) if memo && (memo >> 1) == gen
244
+
245
+ bearing = ::Moxml::Adapter::Leptris.entity_bearing?(self)
246
+ ENTITY_DOC_MEMO[doc] = (gen << 1) | (bearing ? 1 : 0)
247
+ bearing
248
+ end
244
249
 
245
- def [](key)
246
- if key.is_a?(String) && !key.include?(":")
247
- value = NN_ATTRIBUTE.bind_call(self, key)
248
- return value unless value.is_a?(String) && doc_entity_bearing?
250
+ def [](key)
251
+ if key.is_a?(String) && !key.include?(":")
252
+ value = attr_read(key)
253
+ return value unless value.is_a?(String) && doc_entity_bearing?
254
+
255
+ return ::Moxml::Adapter::Leptris.restore_entities(value)
256
+ end
249
257
 
250
- return ::Moxml::Adapter::Leptris.restore_entities(value)
258
+ ELEMENT_CONTRACT_READ.bind_call(self, key)
251
259
  end
252
260
 
253
- ELEMENT_CONTRACT_READ.bind_call(self, key)
261
+ def text
262
+ value = text_read
263
+ value.is_a?(String) && doc_entity_bearing? ? ::Moxml::Adapter::Leptris.restore_entities(value) : value
264
+ end
254
265
  end
266
+ else
267
+ module Reads
268
+ def doc_entity_bearing?
269
+ doc = NN_DOCUMENT.bind_call(self)
270
+ memo = ENTITY_DOC_MEMO[doc]
271
+ gen = ::Moxml::Adapter::Leptris.serialize_generation
272
+ return memo.allbits?(1) if memo && (memo >> 1) == gen
273
+
274
+ bearing = ::Moxml::Adapter::Leptris.entity_bearing?(self)
275
+ ENTITY_DOC_MEMO[doc] = (gen << 1) | (bearing ? 1 : 0)
276
+ bearing
277
+ end
255
278
 
256
- def text
257
- value = NN_CONTENT.bind_call(self)
258
- value.is_a?(String) && doc_entity_bearing? ? ::Moxml::Adapter::Leptris.restore_entities(value) : value
279
+ def [](key)
280
+ if key.is_a?(String) && !key.include?(":")
281
+ value = NN_ATTRIBUTE.bind_call(self, key)
282
+ return value unless value.is_a?(String) && doc_entity_bearing?
283
+
284
+ return ::Moxml::Adapter::Leptris.restore_entities(value)
285
+ end
286
+
287
+ ELEMENT_CONTRACT_READ.bind_call(self, key)
288
+ end
289
+
290
+ def text
291
+ value = NN_CONTENT.bind_call(self)
292
+ value.is_a?(String) && doc_entity_bearing? ? ::Moxml::Adapter::Leptris.restore_entities(value) : value
293
+ end
259
294
  end
260
295
  end
261
296
  ELEMENT.include(Reads)
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.60"
4
+ VERSION = "0.5.61"
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.60
4
+ version: 0.5.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.