[ruby/rdoc] Reduce matched substring allocations

https://github.com/ruby/rdoc/commit/aaed688a97
This commit is contained in:
Nobuyoshi Nakada 2023-12-05 13:22:07 +09:00 committed by git
parent 8bdd28da74
commit c0baa3783f

View File

@ -582,12 +582,12 @@ class RDoc::Parser::C < RDoc::Parser
| ^\s*\#\s*define\s+(\w+)\s+(\w+) | ^\s*\#\s*define\s+(\w+)\s+(\w+)
}xm) do }xm) do
case case
when $1 when name = $3
table[$3] = [:func_def, $1, $2, $~.offset(2)] if !table[$3] || table[$3][0] != :func_def table[name] = [:func_def, $1, $2, $~.offset(2)] if !(t = table[name]) || t[0] != :func_def
when $4 when name = $6
table[$6] = [:macro_def, $4, $5, $~.offset(5), $7] if !table[$6] || table[$6][0] == :macro_alias table[name] = [:macro_def, $4, $5, $~.offset(5), $7] if !(t = table[name]) || t[0] == :macro_alias
when $8 when name = $8
table[$8] ||= [:macro_alias, $9] table[name] ||= [:macro_alias, $9]
end end
end end
table table