|
|
|
|
|
by fbcocq
5719 days ago
|
|
I think the speed increase comes from += creating a new string object every time, whereas << literally concatenates it. Programming the hunches and guesses way on the HN frontpage makes me sad. http://ruby-doc.org/core/classes/String.html#M000807 str + other_str => new_str Concatenation Returns a new String containing other_str concatenated to str. str << fixnum => str
str.concat(fixnum) => str
str << obj => str
str.concat(obj) => str Append Concatenates the given object to str. If the object is a Fixnum between 0 and 255, it is converted to a character before concatenation. |
|