Use String#<< instead of String#+=

I just couldn’t believe this but look:

~/jekyll/jekyll#master$ ruby benchmark/string-concat
Calculating -------------------------------------
                  +=      6367 i/100ms
                  <<    128697 i/100ms
-------------------------------------------------
                  +=     1704.3 (±0.6%) i/s -      12734 in   7.472170s
                  <<  4381212.4 (±6.3%) i/s -   21878490 in   5.014899s

WOW.
This commit is contained in:
Parker Moore 2014-10-22 00:58:20 -07:00
parent 1395d5686b
commit 0511ece2f5
1 changed files with 1 additions and 1 deletions

View File

@ -63,7 +63,7 @@ module Jekyll
.gsub(/\A([^\/])/, '/\1')
# Append a trailing slash to the URL if the unsanitized URL had one
url += "/" if in_url =~ /\/$/
url << "/" if in_url =~ /\/$/
url
end