1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/erb.rb: Render erb with array buffer for function call optimization.

[fix GH-1143]
* lib/rdoc/erb_partial.rb: ditto.
* template/verconf.h.tmpl: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2015-12-15 07:20:07 +00:00
parent 365fae4dd9
commit ec7a964dca
4 changed files with 15 additions and 8 deletions

View file

@ -1,3 +1,10 @@
Tue Dec 15 16:19:26 2015 Takashi Kokubun <takashikkbn@gmail.com>
* lib/erb.rb: Render erb with array buffer for function call optimization.
[fix GH-1143]
* lib/rdoc/erb_partial.rb: ditto.
* template/verconf.h.tmpl: ditto.
Tue Dec 15 13:50:05 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Dec 15 13:50:05 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_oct): [DOC] mention radix indicators. * string.c (rb_str_oct): [DOC] mention radix indicators.

View file

@ -589,7 +589,7 @@ class ERB
end end
def add_insert_cmd(out, content) def add_insert_cmd(out, content)
out.push("#{@insert_cmd}((#{content}).to_s)") out.push("#{@insert_cmd}((#{content}))")
end end
# Compiles an ERB template into Ruby code. Returns an array of the code # Compiles an ERB template into Ruby code. Returns an array of the code
@ -834,10 +834,10 @@ class ERB
# requires the setup of an ERB _compiler_ object. # requires the setup of an ERB _compiler_ object.
# #
def set_eoutvar(compiler, eoutvar = '_erbout') def set_eoutvar(compiler, eoutvar = '_erbout')
compiler.put_cmd = "#{eoutvar}.concat" compiler.put_cmd = "#{eoutvar}.push"
compiler.insert_cmd = "#{eoutvar}.concat" compiler.insert_cmd = "#{eoutvar}.push"
compiler.pre_cmd = ["#{eoutvar} = ''"] compiler.pre_cmd = ["#{eoutvar} = []"]
compiler.post_cmd = ["#{eoutvar}.force_encoding(__ENCODING__)"] compiler.post_cmd = ["#{eoutvar}.join.force_encoding(__ENCODING__)"]
end end
# Generate results and print them. (see ERB#result) # Generate results and print them. (see ERB#result)

View file

@ -11,7 +11,7 @@ class RDoc::ERBPartial < ERB
def set_eoutvar compiler, eoutvar = '_erbout' def set_eoutvar compiler, eoutvar = '_erbout'
super super
compiler.pre_cmd = ["#{eoutvar} ||= ''"] compiler.pre_cmd = ["#{eoutvar} ||= []"]
end end
end end

View file

@ -52,7 +52,7 @@
% R["exec_prefix"] = '"RUBY_EXEC_PREFIX"' % R["exec_prefix"] = '"RUBY_EXEC_PREFIX"'
% R["prefix"] = '"RUBY_EXEC_PREFIX"' % R["prefix"] = '"RUBY_EXEC_PREFIX"'
% exec_prefix_pat = /\A"#{Regexp.quote(rbconfig::CONFIG['exec_prefix'])}(?=\/|\z)/ % exec_prefix_pat = /\A"#{Regexp.quote(rbconfig::CONFIG['exec_prefix'])}(?=\/|\z)/
% _erbout.gsub!(/^(#define\s+(\S+)\s+)(.*)/) { % _erbout = [_erbout.join.gsub!(/^(#define\s+(\S+)\s+)(.*)/) {
% pre, name, repl = $1, $2, $3 % pre, name, repl = $1, $2, $3
% pat = %["#{name}"] % pat = %["#{name}"]
% c = C.merge(R.reject {|key, value| key == name or value.include?(pat)}) % c = C.merge(R.reject {|key, value| key == name or value.include?(pat)})
@ -60,4 +60,4 @@
% repl.gsub!(/^""(?!$)|(.)""$/, '\1') % repl.gsub!(/^""(?!$)|(.)""$/, '\1')
% repl.sub!(exec_prefix_pat, 'RUBY_EXEC_PREFIX"') % repl.sub!(exec_prefix_pat, 'RUBY_EXEC_PREFIX"')
% pre + repl % pre + repl
% } % }]