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
This commit is contained in:
k0kubun 2017-10-21 15:02:46 +00:00
parent 4aed1c7fc9
commit 774b42d643
1 changed files with 7 additions and 7 deletions

View File

@ -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