canon 0.3.78 → 0.3.79
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/lib/canon/version.rb +1 -1
- data/lib/canon/xml/sax_builder.rb +14 -6
- 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: f8ca5b8d655930c1e5292fa9c0ff829a71865ced02ea0c1a0ef9b7ac018f6884
|
|
4
|
+
data.tar.gz: af7939862ab2f737d23c5e10e6c833c66e12abb40bc1d3bfc775c822867b059a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e84e726e14f146cf995468b63872e6b072c85ab30f48857de35d2d6bfc877a53bcfba777cd3c05bb93365607e08a6d48dc2a0d8cbce8aea73c8e6959ceeb2866
|
|
7
|
+
data.tar.gz: 485d7c9a66e7e1a3713700c7be740d345273012dae7db3f24ae2ec1ac22409af054b3705917194cf6e7a374a588a2d27576c4f855d0d10928cf99114465b6562
|
data/lib/canon/version.rb
CHANGED
|
@@ -325,16 +325,24 @@ strip_doctype: false)
|
|
|
325
325
|
result
|
|
326
326
|
end
|
|
327
327
|
|
|
328
|
-
# Parse a QName into prefix and local name
|
|
328
|
+
# Parse a QName into prefix and local name. Memoized per
|
|
329
|
+
# builder — document qnames repeat massively (tens of calls per
|
|
330
|
+
# distinct name), and each uncached call allocates the result
|
|
331
|
+
# array plus split parts. Callers only destructure, so sharing
|
|
332
|
+
# the frozen pair is safe.
|
|
329
333
|
#
|
|
330
334
|
# @param qname [String] QName like "prefix:local" or "local"
|
|
331
335
|
# @return [Array<(String, String)>] [prefix, local_name] - prefix may be nil
|
|
332
336
|
def parse_qname(qname)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
337
|
+
cache = (@qname_cache ||= {})
|
|
338
|
+
cache.fetch(qname) do
|
|
339
|
+
pair = if qname.include?(":")
|
|
340
|
+
parts = qname.split(":", 2)
|
|
341
|
+
[parts[0], parts[1]]
|
|
342
|
+
else
|
|
343
|
+
[nil, qname]
|
|
344
|
+
end
|
|
345
|
+
cache[qname] = pair.freeze
|
|
338
346
|
end
|
|
339
347
|
end
|
|
340
348
|
|