From 2fd7a1abecf377556b8c79b110d31f086b4953f2 Mon Sep 17 00:00:00 2001 From: kk-ds-000 <109396253+kk-ds-000@users.noreply.github.com> Date: Thu, 18 Aug 2022 04:10:39 -0700 Subject: [PATCH] Avoid regex allocations by checking arity condition first --- lib/yard/parser/ruby/ruby_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yard/parser/ruby/ruby_parser.rb b/lib/yard/parser/ruby/ruby_parser.rb index a7085b5e0..912564453 100644 --- a/lib/yard/parser/ruby/ruby_parser.rb +++ b/lib/yard/parser/ruby/ruby_parser.rb @@ -144,7 +144,7 @@ def file_encoding PARSER_EVENT_TABLE.each do |event, arity| node_class = AstNode.node_class_for(event) - if /_new\z/ =~ event.to_s && arity == 0 + if arity == 0 && /_new\z/ =~ event.to_s module_eval(<<-eof, __FILE__, __LINE__ + 1) def on_#{event}(*args) #{node_class}.new(:list, args, :listchar => charno...charno, :listline => lineno..lineno)