--=-lNb1rzhDloJxUGQkRZJC
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Sun, 2007-09-30 at 06:34 +0900, Ari Brown wrote:
> In light of recent criticism and desperation for faster Ruby code, =20
> what are some common practices (little things) that will make code =20
> run faster? IE, if-then or case-when, etc.
>=20
> So far all I have is:
> <<        instead of         +

The most general advice is to minimize the number of method calls you
make, and try to create fewer intermediate objects.  Using << instead of
+ to accumulate strings satisfies the latter.

Another specific instance would be that it usually performs better to
do:

 def foo(x)
   x.y { yield }
 end

than:

 def foo(x, &block)
   x.y &block
 end

(Of course the latter form is still required if #y retains the block as
a Proc object, rather than calling it directly.)

-mental

--=-lNb1rzhDloJxUGQkRZJC
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBG/sevSuZBmZzm14ERAm+kAKDYwgnxJ4avL1ACsMPkxlXHKm+CFgCfSCDr
+gme361a73ERV0VuvdiW9m4=
=jCFG
-----END PGP SIGNATURE-----

--=-lNb1rzhDloJxUGQkRZJC--