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.