diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 15:02:46 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 15:02:46 +0000 |
commit | 774b42d64385c2447ac38802ae0d045f3d7b9e95 (patch) | |
tree | 509d5e38be3d233c408b05591ecf14f47dfc9147 | |
parent | 4aed1c7fc91e8311c827598532bc3e4a48ed6353 (diff) | |
download | ruby-774b42d64385c2447ac38802ae0d045f3d7b9e95.tar.gz |
erb.rb: specify frozen_string_literal: true
for compilation performance.
$ ruby ./benchmark/driver.rb -e "trunk::/Users/k0kubun/.rbenv/versions/trunk/bin/ruby;modified::/Users/k0kubun/.rbenv/versions/modified/bin/ruby" -d ./benchmark -p app_erb
-----------------------------------------------------------
benchmark results:
Execution time (sec)
name trunk modified
app_erb 1.911 1.885
Speedup ratio: compare with the result of `trunk' (greater is better)
name modified
app_erb 1.014
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/erb.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/erb.rb b/lib/erb.rb index 47bb5022cc..36622c44b6 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -1,5 +1,5 @@ # -*- coding: us-ascii -*- -# frozen_string_literal: false +# frozen_string_literal: true # = ERB -- Ruby Templating # # Author:: Masatoshi SEKI @@ -547,7 +547,7 @@ class ERB def initialize(compiler, enc=nil, frozen=nil) @compiler = compiler @line = [] - @script = '' + @script = +'' @script << "#coding:#{enc}\n" if enc @script << "#frozen-string-literal:#{frozen}\n" unless frozen.nil? @compiler.pre_cmd.each do |x| @@ -602,7 +602,7 @@ class ERB magic_comment = detect_magic_comment(s, enc) out = Buffer.new(self, *magic_comment) - self.content = '' + self.content = +'' scanner = make_scanner(s) scanner.scan do |token| next if token.nil? @@ -622,7 +622,7 @@ class ERB case stag when PercentLine add_put_cmd(out, content) if content.size > 0 - self.content = '' + self.content = +'' out.push(stag.to_s) out.cr when :cr @@ -630,11 +630,11 @@ class ERB when '<%', '<%=', '<%#' scanner.stag = stag add_put_cmd(out, content) if content.size > 0 - self.content = '' + self.content = +'' when "\n" content << "\n" add_put_cmd(out, content) - self.content = '' + self.content = +'' when '<%%' content << '<%' else @@ -647,7 +647,7 @@ class ERB when '%>' compile_content(scanner.stag, out) scanner.stag = nil - self.content = '' + self.content = +'' when '%%>' content << '%>' else |