Usa << en lugar de +=
Si no lo veo no creo, me dije.
$ time ruby -e 'a = "A"; 100000.times { a << "A" }'
real 0m0.097s
user 0m0.068s
sys 0m0.004s
$ time ruby -e 'a = "A"; 100000.times { a += "A" }'
real 0m10.123s
user 0m3.273s
sys 0m6.534s
Leido en un tweet y en esta entrada en profundidad.
Tags: Ruby, tip
This entry was posted
on Miércoles, Marzo 25th, 2009 at 22:22 and is filed under Ruby.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Marzo 30th, 2010 at 13:51
http://adriananthonys.easyjournal.com/
Agosto 2nd, 2010 at 2:08
De alguna manera el uso tweeter?
Agosto 3rd, 2010 at 4:28
Erst we landed I retrieved my bag only to issue without accomplishment finished duty. Don’t get me unjust, I dislike custom, but assumption the integral visa collapse I was a bit discomfited that nobody equal cared that I could lawfully succeed the region. The exclusive characteristic invoice I went finished was in Frankfurt and the guy barely looked at my passport, overmuch fewer my visa.
Agosto 3rd, 2010 at 12:06
Once we landed I retrieved my bag exclusive to opening without going through tariff. Don’t get me immoral, I hate tariff, but acknowledged the entire visa collapse I was a bit foiled that nobody symmetric cared that I could legally participate the region. The only permission inactivity I went through was in Metropolis and the guy barely looked at my characteristic, untold inferior my visa.