diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-15 13:38:02 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-15 13:38:02 +0000 |
commit | 2965599aa07633a8db8d3af1db65ac57abc8746b (patch) | |
tree | 96f5cfa15eeca14b9f50429f34604c441729e170 /lib | |
parent | 0b28456d696763cb8478ff69723ce23d5acc53bd (diff) | |
download | ruby-2965599aa07633a8db8d3af1db65ac57abc8746b.tar.gz |
erb.rb: Use String#<< instead of #concat
to optimize String concatenation on rendering.
[fix GH-1612]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/erb.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/erb.rb b/lib/erb.rb index 9483711024..ab65ef3be5 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -281,8 +281,8 @@ class ERB # # compiler = ERB::Compiler.new('<>') # compiler.pre_cmd = ["_erbout=String.new"] - # compiler.put_cmd = "_erbout.concat" - # compiler.insert_cmd = "_erbout.concat" + # compiler.put_cmd = "_erbout.<<" + # compiler.insert_cmd = "_erbout.<<" # compiler.post_cmd = ["_erbout"] # # code, enc = compiler.compile("Got <%= obj %>!\n") @@ -291,7 +291,7 @@ class ERB # <i>Generates</i>: # # #coding:UTF-8 - # _erbout=String.new; _erbout.concat "Got "; _erbout.concat(( obj ).to_s); _erbout.concat "!\n"; _erbout + # _erbout=String.new; _erbout.<< "Got "; _erbout.<<(( obj ).to_s); _erbout.<< "!\n"; _erbout # # By default the output is sent to the print method. For example: # @@ -867,8 +867,8 @@ class ERB # requires the setup of an ERB _compiler_ object. # def set_eoutvar(compiler, eoutvar = '_erbout') - compiler.put_cmd = "#{eoutvar}.concat" - compiler.insert_cmd = "#{eoutvar}.concat" + compiler.put_cmd = "#{eoutvar}.<<" + compiler.insert_cmd = "#{eoutvar}.<<" compiler.pre_cmd = ["#{eoutvar} = String.new"] compiler.post_cmd = ["#{eoutvar}.force_encoding(__ENCODING__)"] end |