ruby-changes:46801
From: k0kubun <ko1@a...>
Date: Sat, 27 May 2017 12:07:02 +0900 (JST)
Subject: [ruby-changes:46801] k0kubun:r58916 (trunk): erb.rb: Use str_uplus instead of rb_str_dup
k0kubun 2017-05-27 12:06:55 +0900 (Sat, 27 May 2017) New Revision: 58916 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58916 Log: erb.rb: Use str_uplus instead of rb_str_dup to skip unnecessary string allocation on frozen_string_literal: false. str_uplus can bypass calling rb_str_dup when OBJ_FROZEN is true. * Before erb_render 1.064 * Afete erb_render 0.909 Modified files: trunk/lib/erb.rb Index: lib/erb.rb =================================================================== --- lib/erb.rb (revision 58915) +++ lib/erb.rb (revision 58916) @@ -280,7 +280,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/lib/erb.rb#L280 # ERB#src: # # compiler = ERB::Compiler.new('<>') - # compiler.pre_cmd = ["_erbout=''.dup"] + # compiler.pre_cmd = ["_erbout=+''"] # compiler.put_cmd = "_erbout.<<" # compiler.insert_cmd = "_erbout.<<" # compiler.post_cmd = ["_erbout"] @@ -291,7 +291,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/lib/erb.rb#L291 # <i>Generates</i>: # # #coding:UTF-8 - # _erbout=''.dup; _erbout.<< -"Got "; _erbout.<<(( obj ).to_s); _erbout.<< -"!\n"; _erbout + # _erbout=+''; _erbout.<< -"Got "; _erbout.<<(( obj ).to_s); _erbout.<< -"!\n"; _erbout # # By default the output is sent to the print method. For example: # @@ -861,7 +861,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/lib/erb.rb#L861 def set_eoutvar(compiler, eoutvar = '_erbout') compiler.put_cmd = "#{eoutvar}.<<" compiler.insert_cmd = "#{eoutvar}.<<" - compiler.pre_cmd = ["#{eoutvar} = ''.dup"] + compiler.pre_cmd = ["#{eoutvar} = +''"] compiler.post_cmd = [eoutvar] end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/