lib/rdoc/parser/ruby.rb: Avoid `.chars.to_a.last`

The code creates a lot of useless objects.
Instead, using a regexp is shorter and faster.
This commit is contained in:
Yusuke Endoh 2019-08-16 11:36:47 +09:00
Родитель 64bffddda1
Коммит cd41378ef9
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -1779,9 +1779,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
comment_body = retrieve_comment_body(tk) comment_body = retrieve_comment_body(tk)
comment += comment_body comment += comment_body
comment += "\n" unless "\n" == comment_body.chars.to_a.last comment << "\n" unless comment_body =~ /\n\z/
if comment_body.size > 1 && "\n" == comment_body.chars.to_a.last then if comment_body.size > 1 && comment_body =~ /\n\z/ then
skip_tkspace_without_nl # leading spaces skip_tkspace_without_nl # leading spaces
end end
tk = get_tk tk = get_tk