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:
parent
4aed1c7fc9
commit
774b42d643
14
lib/erb.rb
14
lib/erb.rb
@ -1,5 +1,5 @@
|
|||||||
# -*- coding: us-ascii -*-
|
# -*- coding: us-ascii -*-
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
# = ERB -- Ruby Templating
|
# = ERB -- Ruby Templating
|
||||||
#
|
#
|
||||||
# Author:: Masatoshi SEKI
|
# Author:: Masatoshi SEKI
|
||||||
@ -547,7 +547,7 @@ class ERB
|
|||||||
def initialize(compiler, enc=nil, frozen=nil)
|
def initialize(compiler, enc=nil, frozen=nil)
|
||||||
@compiler = compiler
|
@compiler = compiler
|
||||||
@line = []
|
@line = []
|
||||||
@script = ''
|
@script = +''
|
||||||
@script << "#coding:#{enc}\n" if enc
|
@script << "#coding:#{enc}\n" if enc
|
||||||
@script << "#frozen-string-literal:#{frozen}\n" unless frozen.nil?
|
@script << "#frozen-string-literal:#{frozen}\n" unless frozen.nil?
|
||||||
@compiler.pre_cmd.each do |x|
|
@compiler.pre_cmd.each do |x|
|
||||||
@ -602,7 +602,7 @@ class ERB
|
|||||||
magic_comment = detect_magic_comment(s, enc)
|
magic_comment = detect_magic_comment(s, enc)
|
||||||
out = Buffer.new(self, *magic_comment)
|
out = Buffer.new(self, *magic_comment)
|
||||||
|
|
||||||
self.content = ''
|
self.content = +''
|
||||||
scanner = make_scanner(s)
|
scanner = make_scanner(s)
|
||||||
scanner.scan do |token|
|
scanner.scan do |token|
|
||||||
next if token.nil?
|
next if token.nil?
|
||||||
@ -622,7 +622,7 @@ class ERB
|
|||||||
case stag
|
case stag
|
||||||
when PercentLine
|
when PercentLine
|
||||||
add_put_cmd(out, content) if content.size > 0
|
add_put_cmd(out, content) if content.size > 0
|
||||||
self.content = ''
|
self.content = +''
|
||||||
out.push(stag.to_s)
|
out.push(stag.to_s)
|
||||||
out.cr
|
out.cr
|
||||||
when :cr
|
when :cr
|
||||||
@ -630,11 +630,11 @@ class ERB
|
|||||||
when '<%', '<%=', '<%#'
|
when '<%', '<%=', '<%#'
|
||||||
scanner.stag = stag
|
scanner.stag = stag
|
||||||
add_put_cmd(out, content) if content.size > 0
|
add_put_cmd(out, content) if content.size > 0
|
||||||
self.content = ''
|
self.content = +''
|
||||||
when "\n"
|
when "\n"
|
||||||
content << "\n"
|
content << "\n"
|
||||||
add_put_cmd(out, content)
|
add_put_cmd(out, content)
|
||||||
self.content = ''
|
self.content = +''
|
||||||
when '<%%'
|
when '<%%'
|
||||||
content << '<%'
|
content << '<%'
|
||||||
else
|
else
|
||||||
@ -647,7 +647,7 @@ class ERB
|
|||||||
when '%>'
|
when '%>'
|
||||||
compile_content(scanner.stag, out)
|
compile_content(scanner.stag, out)
|
||||||
scanner.stag = nil
|
scanner.stag = nil
|
||||||
self.content = ''
|
self.content = +''
|
||||||
when '%%>'
|
when '%%>'
|
||||||
content << '%>'
|
content << '%>'
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user