Improve the performance using the hints by rubocop-performance and fasterer
@anew-bhav y travaille déjà.
Depuis le 31/5/2021.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 38/100
- Type d'issue
- Refactorisation
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- ruby
- Domaine
- performance
Piste de recherche
Commencez par les fichiers et les emplacements de lignes indiqués dans les rapports de rubocop-performance et fasterer, en particulier les fichiers parser, XPath, quickpath, node, element et doctype. Exécutez les deux outils sur le projet et examinez chaque modification suggérée afin de préserver le comportement. C’est terminé lorsque les infractions signalées sont corrigées et que les vérifications existantes réussissent toujours.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
rubocop-performance (see https://github.com/rubocop-hq/rubocop-performance ) says:
Offenses:
/usr/lib/ruby/2.7.0/rexml/attlistdecl.rb:45:7: C: Performance/InefficientHashSearch: Use #key? instead of #keys.include?.
@pairs.keys.include? key
^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/doctype.rb:201:7: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
quoted_string =~ /^[\'\"].*[\'\"]$/ ?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/element.rb:255:43: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
prefix = "xmlns:#{prefix}" unless prefix =~ /^xmlns:/
^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/entity.rb:44:12: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
if stream[2] =~ /SYSTEM|PUBLIC/
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/node.rb:56:9: C: Performance/RedundantBlockCall: Use yield instead of block.call.
block.call(node)
^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/node.rb:65:24: C: Performance/RedundantBlockCall: Use yield instead of block.call.
return node if block.call(node)
^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/parseexception.rb:32:67: C: Performance/StringReplacement: Use tr instead of gsub.
err << @source.buffer[0..80].force_encoding("ASCII-8BIT").gsub(/\n/, ' ')
^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/parsers/baseparser.rb:476:25: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
return false if /\AUTF-16\z/i =~ xml_declaration_encoding
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/parsers/pullparser.rb:73:29: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
event[2] unless event[2] =~ /PUBLIC|SYSTEM/
^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/parsers/treeparser.rb:81:54: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
entities[ event[1] ] = event[2] unless event[2] =~ /PUBLIC|SYSTEM/
^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/parsers/xpathparser.rb:304:14: C: Performance/RegexpMatch: Use match? instead of !~ when MatchData is not used.
if path !~ /^\s*\)/
^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/parsers/xpathparser.rb:539:41: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w*]/
^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/ruby/2.7.0/rexml/quickpath.rb:108:49: C: Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
matches = filter( elements.dup, rest ) if axe_name =~ /-or-self$/u
^^^^^^^^^^^^^^^^^^^^^^^^
49 files inspected, 13 offenses detected
fasterer (see https://github.com/DamirSvrtan/fasterer) says:
validation/relaxng.rb:416 Calling argumentless methods within blocks is slower than using symbol to proc.
validation/relaxng.rb:523 Calling argumentless methods within blocks is slower than using symbol to proc.
parsers/xpathparser.rb:602 For loop is slower than using each.
parsers/baseparser.rb:381 For loop is slower than using each.
formatters/default.rb:70 Calling argumentless methods within blocks is slower than using symbol to proc.
xpath_parser.rb:105 For loop is slower than using each.
xpath_parser.rb:120 For loop is slower than using each.
xpath_parser.rb:458 Enumerable#sort is slower than Enumerable#sort_by.
xpath_parser.rb:590 Using each_with_index is slower than while loop.
quickpath.rb:88 Calling argumentless methods within blocks is slower than using symbol to proc.
quickpath.rb:133 Calling argumentless methods within blocks is slower than using symbol to proc.
quickpath.rb:135 Calling argumentless methods within blocks is slower than using symbol to proc.
quickpath.rb:138 Calling argumentless methods within blocks is slower than using symbol to proc.
node.rb:54 Calling blocks with call is slower than yielding.
node.rb:63 Calling blocks with call is slower than yielding.
functions.rb:42 Calling argumentless methods within blocks is slower than using symbol to proc.
element.rb:1068 Hash#fetch with second argument is slower than Hash#fetch with block.
element.rb:1075 Hash#fetch with second argument is slower than Hash#fetch with block.
element.rb:1128 Hash#fetch with second argument is slower than Hash#fetch with block.
element.rb:1212 Hash#fetch with second argument is slower than Hash#fetch with block.
element.rb:1246 Calling argumentless methods within blocks is slower than using symbol to proc.
doctype.rb:283 Use attr_reader for reading ivars.
49 files inspected, 22 offenses detected
- Langage dominant
- Ruby
- Étoiles
- 181
- Forks
- 104
- Merge moyen
- 11 h 3 min
- PR mergées (30 j)
- 1
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ruby/rexml
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
-
XPath underscored function name is wrongly acceptedPeut-être pris @sjh9714 l’a pris il y a 46 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
Toutes les issues de ruby/rexml
Issues similaires
-
🐞 bug pending triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
CircuitVerse/CircuitVerse#8031 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
riscv/riscv-unified-db#2740 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
iOS podspec depends on `React-Codegen`, which resolves to an unrelated pod on CocoaPods trunkOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
GantMan/jail-monkey#380 ·