moxml 0.5.41 → 0.5.42
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 +4 -4
- data/docs/_pages/performance.adoc +13 -6
- data/lib/moxml/adapter/leptris.rb +42 -10
- data/lib/moxml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d447f74ea4b1c546e83fbb94819c6043a1fa48e0f9932ac7202009cecff63e1e
|
|
4
|
+
data.tar.gz: 4c33c0af41d9c628ecc993d7015d4e827d1d451b266dd7ad4145f00b322670a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ebdc376975c3893facd06d793a04eebdfa9387814b131b9f0c5aecbd047fb57dcfadba80c40eee8ff60e52b4a7cbf1e886e67909b5f9b46623ca91b75cdb04b5
|
|
7
|
+
data.tar.gz: 9cf48a7154d6336a24504df0ec1cd62d689859f1b8f9df85e313bf69f1db97a17191e813b7f2e10bdd8565644dae88f6b323b1cd109e64995e26ea8d537bb67a
|
|
@@ -293,12 +293,19 @@ scratch there. 1.9.163.2 moved the bulk into C and fixed the
|
|
|
293
293
|
truncation — newer bindings use their C path (version-memoized,
|
|
294
294
|
cheaper than a per-call count+copy).
|
|
295
295
|
|
|
296
|
-
The native
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
per-
|
|
301
|
-
|
|
296
|
+
The native builder factories (native_create_element/text) are
|
|
297
|
+
adopted from 1.9.163.5, where native mutations became
|
|
298
|
+
version-coherent with the binding (leptris-ruby#204/#208 — both
|
|
299
|
+
surfaces' memos drop on mutation). The earlier rejection — stale
|
|
300
|
+
binding memos plus a per-attach `to_binding` bridge costing more
|
|
301
|
+
than the factory saved (5816 -> 7697ns vs nokogiri 1750) — no
|
|
302
|
+
longer applies: `add_child` carries a both-native fast path with
|
|
303
|
+
no bridge, and `doc_for` reads the 1.9.163.5 `NativeNode#document`
|
|
304
|
+
accessor instead of the parent climb. create ×2 + attach:
|
|
305
|
+
**4846 -> 2333ns (0.30x -> 0.78x of raw nokogiri)**. Attribute
|
|
306
|
+
writes on native nodes still bridge (the native layer has no
|
|
307
|
+
`[]=`), and the native `attributes` hash (name → String) does not
|
|
308
|
+
fit the attribute-node contract — enumeration stays bridged.
|
|
302
309
|
|
|
303
310
|
Serialize (document, 30KB): passing `encoding: "UTF-8"` when it
|
|
304
311
|
equals the document's own ran a conversion pass for byte-identical
|
|
@@ -65,6 +65,15 @@ module Moxml
|
|
|
65
65
|
defined?(::Leptris::XML::NativeNode) &&
|
|
66
66
|
Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.163.2")
|
|
67
67
|
|
|
68
|
+
# 1.9.163.5 (leptris-ruby#204/#208): native mutations are
|
|
69
|
+
# version-coherent with the binding (both surfaces' memos
|
|
70
|
+
# drop on mutation) — the builder factories and native
|
|
71
|
+
# add_child are adoptable end-to-end; NativeNode grew a
|
|
72
|
+
# document accessor and line numbers.
|
|
73
|
+
NATIVE_MUTATIONS_COHERENT =
|
|
74
|
+
defined?(::Leptris::XML::NativeNode) &&
|
|
75
|
+
Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.163.5")
|
|
76
|
+
|
|
68
77
|
# 1.9.163.2 moved the native bulk children into C
|
|
69
78
|
# (Native.bulk_children) and fixed the 512 truncation
|
|
70
79
|
# (leptris-ruby#202). The 162.6-163.1 window carries the
|
|
@@ -130,6 +139,10 @@ module Moxml
|
|
|
130
139
|
# to the root (C-bound reads) and look the doc up in the
|
|
131
140
|
# root registry. Detached subtrees answer nil.
|
|
132
141
|
def doc_for(node)
|
|
142
|
+
# The 1.9.163.5 native layer exposes the owning document
|
|
143
|
+
# directly; the root climb serves older bindings.
|
|
144
|
+
return node.document if NATIVE_MUTATIONS_COHERENT
|
|
145
|
+
|
|
133
146
|
current = node
|
|
134
147
|
current = current.parent while current&.parent
|
|
135
148
|
@native_doc_roots[current]
|
|
@@ -477,18 +490,24 @@ module Moxml
|
|
|
477
490
|
::Leptris::XML::Document.create
|
|
478
491
|
end
|
|
479
492
|
|
|
480
|
-
#
|
|
481
|
-
#
|
|
482
|
-
#
|
|
483
|
-
#
|
|
484
|
-
#
|
|
485
|
-
# that costs more than the factory saves (create+attach
|
|
486
|
-
# measured 5816 -> 7697ns vs nokogiri 1750).
|
|
493
|
+
# Native builder factories: one C call and a TypedData wrap.
|
|
494
|
+
# Adopted from 1.9.163.5, where native mutations became
|
|
495
|
+
# version-coherent (leptris-ruby#204/#208) — the earlier
|
|
496
|
+
# rejection (stale binding memos + per-attach bridge cost)
|
|
497
|
+
# no longer applies: add_child carries a native fast path.
|
|
487
498
|
def create_native_element(name, owner_doc = nil)
|
|
499
|
+
if NATIVE_MUTATIONS_COHERENT && owner_doc
|
|
500
|
+
return owner_doc.native_create_element(name.to_s)
|
|
501
|
+
end
|
|
502
|
+
|
|
488
503
|
(owner_doc || create_document).create_element(name.to_s)
|
|
489
504
|
end
|
|
490
505
|
|
|
491
506
|
def create_native_text(content, owner_doc = nil)
|
|
507
|
+
if NATIVE_MUTATIONS_COHERENT && owner_doc
|
|
508
|
+
return owner_doc.native_create_text(content)
|
|
509
|
+
end
|
|
510
|
+
|
|
492
511
|
(owner_doc || create_document).create_text_node(content)
|
|
493
512
|
end
|
|
494
513
|
|
|
@@ -986,6 +1005,11 @@ module Moxml
|
|
|
986
1005
|
end
|
|
987
1006
|
|
|
988
1007
|
def line_number(node)
|
|
1008
|
+
if NATIVE_MUTATIONS_COHERENT &&
|
|
1009
|
+
node.is_a?(::Leptris::XML::NativeNode)
|
|
1010
|
+
line = node.line
|
|
1011
|
+
return line.nil? || line.zero? ? nil : line
|
|
1012
|
+
end
|
|
989
1013
|
return nil unless node.is_a?(::Leptris::XML::Node)
|
|
990
1014
|
|
|
991
1015
|
line = node.line
|
|
@@ -1050,7 +1074,9 @@ module Moxml
|
|
|
1050
1074
|
end
|
|
1051
1075
|
|
|
1052
1076
|
def add_child(parent, child)
|
|
1053
|
-
if NATIVE_READ_LAYER
|
|
1077
|
+
if NATIVE_READ_LAYER && !(NATIVE_MUTATIONS_COHERENT &&
|
|
1078
|
+
parent.is_a?(::Leptris::XML::NativeNode) &&
|
|
1079
|
+
child.is_a?(::Leptris::XML::NativeNode))
|
|
1054
1080
|
parent = to_binding(parent)
|
|
1055
1081
|
child = to_binding(child)
|
|
1056
1082
|
end
|
|
@@ -1070,7 +1096,10 @@ module Moxml
|
|
|
1070
1096
|
end
|
|
1071
1097
|
|
|
1072
1098
|
def add_previous_sibling(node, new_node)
|
|
1073
|
-
|
|
1099
|
+
if NATIVE_READ_LAYER
|
|
1100
|
+
node = to_binding(node)
|
|
1101
|
+
new_node = to_binding(new_node)
|
|
1102
|
+
end
|
|
1074
1103
|
# A PI inserted before the root lives at document level in
|
|
1075
1104
|
# libleptris's model, not in the element tree.
|
|
1076
1105
|
if new_node.is_a?(::Leptris::XML::ProcessingInstruction) &&
|
|
@@ -1082,7 +1111,10 @@ module Moxml
|
|
|
1082
1111
|
end
|
|
1083
1112
|
|
|
1084
1113
|
def add_next_sibling(node, new_node)
|
|
1085
|
-
|
|
1114
|
+
if NATIVE_READ_LAYER
|
|
1115
|
+
node = to_binding(node)
|
|
1116
|
+
new_node = to_binding(new_node)
|
|
1117
|
+
end
|
|
1086
1118
|
node.add_next_sibling(new_node)
|
|
1087
1119
|
end
|
|
1088
1120
|
|
data/lib/moxml/version.rb
CHANGED