Skip to content

Commit e167846

Browse files
authored
Merge pull request #1455 from kk-ds-000/perf/avoid-more-regexes
Avoid regex allocations by checking arity condition first
2 parents 134be75 + 2fd7a1a commit e167846

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/yard/parser/ruby/ruby_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def file_encoding
144144
PARSER_EVENT_TABLE.each do |event, arity|
145145
node_class = AstNode.node_class_for(event)
146146

147-
if /_new\z/ =~ event.to_s && arity == 0
147+
if arity == 0 && /_new\z/ =~ event.to_s
148148
module_eval(<<-eof, __FILE__, __LINE__ + 1)
149149
def on_#{event}(*args)
150150
#{node_class}.new(:list, args, :listchar => charno...charno, :listline => lineno..lineno)

0 commit comments

Comments
 (0)