Skip to content

Commit

Permalink
Merge pull request #1455 from kk-ds-000/perf/avoid-more-regexes
Browse files Browse the repository at this point in the history
Avoid regex allocations by checking arity condition first
  • Loading branch information
lsegal authored Sep 3, 2022
2 parents 134be75 + 2fd7a1a commit e167846
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/yard/parser/ruby/ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e167846

Please sign in to comment.