ruby-changes:57073
From: Yusuke <ko1@a...>
Date: Fri, 16 Aug 2019 11:42:35 +0900 (JST)
Subject: [ruby-changes:57073] Yusuke Endoh: cd41378ef9 (master): lib/rdoc/parser/ruby.rb: Avoid `.chars.to_a.last`
https://git.ruby-lang.org/ruby.git/commit/?id=cd41378ef9 From cd41378ef906c279ee925a0f5d6ba3bf606953db Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Fri, 16 Aug 2019 11:36:47 +0900 Subject: 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. diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 8da19cf..4d6c038 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -1779,9 +1779,9 @@ class RDoc::Parser::Ruby < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/ruby.rb#L1779 while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do comment_body = retrieve_comment_body(tk) 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 end tk = get_tk -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/