Module: Moxml::Adapter::Leptris::Identity::Reads
- Defined in:
- 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
263 264 265 266 267 268 269 270 271 272 |
# File 'lib/moxml/adapter/leptris.rb', line 263 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.
252 253 254 255 256 257 258 259 260 261 |
# File 'lib/moxml/adapter/leptris.rb', line 252 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
274 275 276 277 |
# File 'lib/moxml/adapter/leptris.rb', line 274 def text value = text_read value.is_a?(String) && doc_entity_bearing? ? ::Moxml::Adapter::Leptris.restore_entities(value) : value end |