these speed quirks are interesting… do we have something similar on wiki?
···
-----Original Message-----
From: Dominik Werder [mailto:dwerder@gmx.net]
Sent: Monday, June 16, 2003 4:18 PM
To: ruby-talk@ruby-lang.org
Subject: Re: Hispeed String concatI found also something interesting:
“Pre#{i.to_s}Post” seams to me cheaper than ‘Pre’<<i.to_s<<‘Post’
although ruby has to parse the double quoted string?
bye!
DominikOften ‘<<’ is fast, but not always.
In one application, where I was generating a CVS file from
a largish
SQL
result set, I made the program over 100 times faster by changingresult = “”
for r in results
csv_string = to_csv(r)
result << csv_string
endto
result =
for r in results
csv_string = to_csv(r)
result << csv_string
end
result = result.join