Module: Moxml::Adapter::Leptris::Identity::Reads
- Defined in:
- lib/moxml/adapter/leptris.rb,
lib/moxml/adapter/leptris.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#doc_entity_bearing? ⇒ Boolean
Marker presence is a DOCUMENT fact, but the wrapper memo re-derives it per node (the per-read machinery was ~a quarter of the consumer walk).
- #text ⇒ Object
Instance Method Details
#[](key) ⇒ Object
253 254 255 256 257 258 259 260 261 262 |
# File 'lib/moxml/adapter/leptris.rb', line 253 def [](key) if key.is_a?(String) && !key.include?(":") value = attr_read(key) return value unless value.is_a?(String) && doc_entity_bearing? return ::Moxml::Adapter::Leptris.restore_entities(value) end ELEMENT_CONTRACT_READ.bind_call(self, key) end |
#doc_entity_bearing? ⇒ Boolean
Marker presence is a DOCUMENT fact, but the wrapper memo re-derives it per node (the per-read machinery was ~a quarter of the consumer walk). Doc-level WeakMap, generation-stamped into one Integer (immediates make safe weak values): one C document read plus one map hit per bare read. Entries die with their documents; a stale generation re-derives.
242 243 244 245 246 247 248 249 250 251 |
# File 'lib/moxml/adapter/leptris.rb', line 242 def doc_entity_bearing? doc = NN_DOCUMENT.bind_call(self) memo = ENTITY_DOC_MEMO[doc] gen = ::Moxml::Adapter::Leptris.serialize_generation return memo.allbits?(1) if memo && (memo >> 1) == gen bearing = ::Moxml::Adapter::Leptris.entity_bearing?(self) ENTITY_DOC_MEMO[doc] = (gen << 1) | (bearing ? 1 : 0) bearing end |
#text ⇒ Object
264 265 266 267 |
# File 'lib/moxml/adapter/leptris.rb', line 264 def text value = text_read value.is_a?(String) && doc_entity_bearing? ? ::Moxml::Adapter::Leptris.restore_entities(value) : value end |