canon 0.3.73 → 0.3.74

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: a656f224e2c137824203586534d57e2520f73a6eb87ad3b55221f6152ff498bd
4
- data.tar.gz: 551442b8a8a2a65b72bc58cfdeee95c3c080eff3447340b35b8985837dfba909
3
+ metadata.gz: 5f292cf264aa11a0a6e3dbf70798066038994c028097e29c914b8e44e1f31a5b
4
+ data.tar.gz: fc9b51e11a1b47a2eb69deae1637fe1592beecb074c7f1fda6a783ef54fcc67f
5
5
  SHA512:
6
- metadata.gz: 97c1dde7629457c696a934eedd106196083e9be8e2d0b610b008614691fbb77acdb8fdfb6a8a382e25c9ec0a7a2d3964112cd807cce4244c672b891c0c72e654
7
- data.tar.gz: 329f978af27f4ce8bdc0a55c6d87b88ba99e3698f0f06bdae7cb29415a46debc9ee01748b06871de5e662b058b65b945d2d4a05114c12acc954f22a5b095ca29
6
+ metadata.gz: 6015ad5de2bc0b7cc61175e0b500488a46ab2f3644f0bea45c2e8442d30df4888fcbdedbc723120864c48da0d0b080a34bf61ac0595e42a075a9ab0d813cbb98
7
+ data.tar.gz: df113103c44a2629faa333f7559430e22b4881698efa09e516df21514814d7d343d0dfaf8b199e0a0c9309c72fbe7faa493d41cba0015fed4afa5750f27a8999
@@ -14,6 +14,18 @@ module Canon
14
14
  # @param differences [Array] Array to append differences to
15
15
  # @return [Symbol] Comparison result
16
16
  def self.compare(node1, node2, opts, differences)
17
+ # FAST PATH: identical raw attribute lists on canon element
18
+ # pairs — same names, values, namespaces, in the same
19
+ # order — are trivially equivalent after any filtering or
20
+ # normalization: name- and content-based ignores drop both
21
+ # sides alike, and identical values process identically
22
+ # under every value behavior. Skips the per-pair
23
+ # filtered-hash rebuilds entirely.
24
+ if canon_elements?(node1, node2) &&
25
+ node1.attribute_nodes == node2.attribute_nodes
26
+ return Comparison::EQUIVALENT
27
+ end
28
+
17
29
  # Get attributes using the appropriate method for each node type
18
30
  raw_attrs1 = get_raw_attributes(node1)
19
31
  raw_attrs2 = get_raw_attributes(node2)
@@ -193,6 +205,11 @@ differences)
193
205
  end
194
206
  end
195
207
  end
208
+
209
+ def self.canon_elements?(node1, node2)
210
+ node1.is_a?(Canon::Xml::Nodes::ElementNode) &&
211
+ node2.is_a?(Canon::Xml::Nodes::ElementNode)
212
+ end
196
213
  end
197
214
  end
198
215
  end
@@ -57,13 +57,20 @@ module Canon
57
57
  #
58
58
  # @param node [Object] Node to extract namespace declarations from
59
59
  # @return [Hash] Hash of prefix => URI mappings
60
+ # Most elements declare no namespaces — their extract result
61
+ # is this shared frozen hash, not a per-call allocation.
62
+ NO_DECLARATIONS = {}.freeze
63
+
60
64
  def self.extract_declarations(node)
61
65
  declarations = {}
62
66
 
63
67
  if node.is_a?(Canon::Xml::Node)
64
68
  if node.namespace_nodes
65
- return extract_from_namespace_nodes(node.namespace_nodes,
66
- declarations)
69
+ return declarations.empty? ? NO_DECLARATIONS : declarations if
70
+ extract_from_namespace_nodes(node.namespace_nodes,
71
+ declarations).empty?
72
+
73
+ return declarations
67
74
  end
68
75
 
69
76
  raw_attrs = node.attribute_nodes
@@ -77,7 +84,7 @@ module Canon
77
84
  extract_from_hash_attributes(raw_attrs, declarations)
78
85
  end
79
86
 
80
- declarations
87
+ declarations.empty? ? NO_DECLARATIONS : declarations
81
88
  end
82
89
 
83
90
  # Extract from Canon::Xml::Node namespace_nodes
data/lib/canon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canon
4
- VERSION = "0.3.73"
4
+ VERSION = "0.3.74"
5
5
  end
@@ -19,6 +19,18 @@ module Canon
19
19
  :attribute
20
20
  end
21
21
 
22
+ # Value equality for the comparison fast paths: name, value,
23
+ # namespace URI, and prefix — never parent or object
24
+ # identity. Only == (not eql?/hash): attribute nodes are
25
+ # never hash keys.
26
+ def ==(other)
27
+ other.is_a?(AttributeNode) &&
28
+ name == other.name &&
29
+ value == other.value &&
30
+ namespace_uri == other.namespace_uri &&
31
+ prefix == other.prefix
32
+ end
33
+
22
34
  def local_name
23
35
  name
24
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.73
4
+ version: 0.3.74
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-25 00:00:00.000000000 Z
11
+ date: 2026-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs