moxml 0.5.44 → 0.5.45

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: cd5c99b547004d2f6521f882b006da2b612ee74cabf92775a3b061d9f096bc20
4
- data.tar.gz: 652bce88c043068ecd97ef7008044557f764661a2e792f1128d435d4e83d715a
3
+ metadata.gz: f552fee96842dca761f5e88ba1f5074e6cfdaef32411b012e2bf30a6736a16c4
4
+ data.tar.gz: 68c734aa63688134b897a1e29e8abfa292a02534daefd278b727122ad952e4e3
5
5
  SHA512:
6
- metadata.gz: ba8297809db361e15cac3cbfbc132aa5545ceee6fe4e3d8b7df9a6250e7585ce930eaf7ba7d15de155975848f0d2deb205dcf8b0ebbdd3e00d96cbfc8d758633
7
- data.tar.gz: 982406a0ff5f858aeed1569fd4ca1d4536bbb2b9841d791b4f560475b19b77641db0831fac7efd6760c3493216a9db8635de55d5e146f158cc0f16297fc97895
6
+ metadata.gz: ff775d10b05c5e60fcbf59c66e49284b841e4148b7da7766393b351b47bb626697a34bb5f30cf0d697d8a578ed07c1a9b8b7987507364c436c7c274be380843f
7
+ data.tar.gz: 7bbaef0118ea13de356dc95041dca057d59373f96eec6a4621a38d1cce07b283ca682b3fd2db77eea34f8d9252aaca821cf2651cbbbebbf0e7e171dd0d51f0f5
@@ -139,27 +139,43 @@ module Moxml
139
139
  # facade's canonical form (checked post-hoc: a source
140
140
  # declaration carrying standalone or another version would
141
141
  # diverge).
142
+ # 1.9.174 attached leptris_document_first_child (libleptris
143
+ # 1.9.174): pointer probe for the single-child document
144
+ # shape without wrapping the child chain.
145
+ DOCUMENT_CHILD_PTRS =
146
+ ::Leptris::XML::FFI.respond_to?(:leptris_document_first_child)
147
+
142
148
  def fast_document_output(doc, options)
143
149
  return nil unless LIBXML2_LAYOUT_PARITY
144
- return nil if attachments.get(doc, :declaration) ||
145
- attachments.get(doc, :doctype) ||
146
- attachments.get(doc, :document_text) ||
147
- attachments.get(doc, :entity_markers)
150
+ return nil unless attachments.none_set?(
151
+ doc, %i[declaration doctype document_text entity_markers]
152
+ )
148
153
 
149
154
  include_decl = !options[:no_declaration] && options.fetch(:declaration) do
150
155
  document_has_declaration?(doc)
151
156
  end
152
157
 
153
- root_seen = false
154
- doc.children.each do |child|
155
- if child.is_a?(::Leptris::XML::Element)
156
- return nil if root_seen
157
-
158
- root_seen = true
159
- elsif root_seen
160
- # Epilog parts glue directly to the root in the engine's
161
- # document output — compose those.
162
- return nil
158
+ # Exactly one document child — the root — is the common
159
+ # parsed shape; pointer probes decide it without wrapping
160
+ # the child chain. Anything else (prolog/epilog parts,
161
+ # multi-root) falls back to the scan.
162
+ root = doc.root
163
+ single_child = DOCUMENT_CHILD_PTRS && root &&
164
+ ::Leptris::XML::FFI.leptris_document_first_child(doc.c_ptr)
165
+ .address == root.c_ptr.address &&
166
+ root.next_sibling.nil?
167
+ unless single_child
168
+ root_seen = false
169
+ doc.children.each do |child|
170
+ if child.is_a?(::Leptris::XML::Element)
171
+ return nil if root_seen
172
+
173
+ root_seen = true
174
+ elsif root_seen
175
+ # Epilog parts glue directly to the root in the engine's
176
+ # document output — compose those.
177
+ return nil
178
+ end
163
179
  end
164
180
  end
165
181
 
@@ -43,6 +43,13 @@ module Moxml
43
43
  end
44
44
  end
45
45
 
46
+ def none_set?(native, keys)
47
+ h = @data[native.object_id]
48
+ return true if h.nil?
49
+
50
+ keys.none? { |key| h.key?(key) }
51
+ end
52
+
46
53
  def key?(native, key)
47
54
  h = @data[native.object_id]
48
55
  !h.nil? && h.key?(key)
@@ -13,6 +13,10 @@ module Moxml
13
13
  native.instance_variable_set(attachment_ivar_name(key), value)
14
14
  end
15
15
 
16
+ def none_set?(native, keys)
17
+ keys.none? { |key| native.instance_variable_defined?(attachment_ivar_name(key)) }
18
+ end
19
+
16
20
  def key?(native, key)
17
21
  native.instance_variable_defined?(attachment_ivar_name(key))
18
22
  end
@@ -20,6 +20,12 @@ module Moxml
20
20
  @backend.get(native, key)
21
21
  end
22
22
 
23
+ # One probe for "none of these keys are set" — the document
24
+ # serialize gate asks about four keys per call.
25
+ def none_set?(native, keys)
26
+ @backend.none_set?(native, keys)
27
+ end
28
+
23
29
  def set(native, key, value)
24
30
  @backend.set(native, key, value)
25
31
  end
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.44"
4
+ VERSION = "0.5.45"
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.44
4
+ version: 0.5.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.