canon 0.3.34 → 0.3.35

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: af3e6b392ac406de109410e886a3bd12371cc9e5038d3c08833b6b3d71b6ac69
4
- data.tar.gz: 464804eeac7d4390eb1e6dc44b0759bf45c4d2cd78d5e113ecc5459edb753821
3
+ metadata.gz: 746a0b0b72cc9111986fb3aab9b8c5de994d71b30a011983665b5a24130b092c
4
+ data.tar.gz: e9e5a262b99c0e44c2f11385e911faaf5216b52f32bc027d1a0ae82f0bae985e
5
5
  SHA512:
6
- metadata.gz: 7b1556a7e0bce22da9c862785d24e2ad5176d26fd6f82c97640fe30597d4eed18a2b298d771abcd4b81e9b4fee67eaff4f1b423ccfd798a903d77239ee2925e5
7
- data.tar.gz: ae481888161bbf62db1b014cd3adaa28ef9bfa39aa7112cae2075a850242276d458445e511f84737ba62a20d1a2bb313132d5e962c331d017f66d69d61e238c3
6
+ metadata.gz: 9edbbe4c9eb6adb6218b2d282f1ac030fa4642ece72cedae34b54ea6cbac987acfd46bebbf1277da017b4bfcf511be98f41c64951fee9d7034d1410f8414a38b
7
+ data.tar.gz: 23d088e8fb394d5f36553b64f9e05955f788ca85615147878d6116552ed2ac3b297ebdc739604de009c754a5a8600a57cad97668c6c325a018635d6c6010df04
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.34"
4
+ VERSION = "0.3.35"
5
5
  end
@@ -447,7 +447,16 @@ module Canon
447
447
  map = {}
448
448
 
449
449
  elements.each do |elem|
450
- class_attr = elem.attribute_nodes.find { |a| a.name == "class" }
450
+ class_attr = nil
451
+ attrs = elem.attribute_nodes
452
+ j = 0
453
+ while j < attrs.length
454
+ if attrs[j].name == "class"
455
+ class_attr = attrs[j]
456
+ break
457
+ end
458
+ j += 1
459
+ end
451
460
  next unless class_attr
452
461
 
453
462
  # Use element name + class as key to handle multiple element types
@@ -458,11 +467,24 @@ module Canon
458
467
  map
459
468
  end
460
469
 
461
- # Extract identity from element attributes
470
+ # Extract identity from element attributes. Index loops, not
471
+ # find/detect blocks — Enumerable#find allocates ~3 objects per
472
+ # call on CRuby 3.4 and this runs per element (both sides) on
473
+ # every comparison level.
462
474
  def extract_identity(elem)
463
- @identity_attrs.each do |attr_name|
464
- attr = elem.attribute_nodes.find { |a| a.name == attr_name }
465
- return attr.value if attr
475
+ attrs = elem.attribute_nodes
476
+ i = 0
477
+ identity_count = @identity_attrs.length
478
+ while i < identity_count
479
+ attr_name = @identity_attrs[i]
480
+ j = 0
481
+ attr_count = attrs.length
482
+ while j < attr_count
483
+ return attrs[j].value if attrs[j].name == attr_name
484
+
485
+ j += 1
486
+ end
487
+ i += 1
466
488
  end
467
489
  nil
468
490
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.34
4
+ version: 0.3.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.