From: David Vallner Date: 2006-10-30T09:02:39+09:00 Subject: Re: Define a hash using %q? --------------enigBCC0175C63B7AE6037D9B452 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Robert Klemme wrote: >> Well, if Ruby had clean blocks, the method using #inject might be more= >> efficient - I don't know how expensive the implicit hash construction >> for method parameters is. Smalltalk muscle memory working there? >=20 > I am not sure what you are at here. Object creation always costs - eve= n > small hashes. Reason is memory allocation and GC management overhead= =2E >=20 I meant that with clean blocks, to_enum(:each_slice, 2).to_a.inject({}) { |h, (k, v)| h[k] =3D v) } might be the fastest variant because you coul= d use a non-closure lambda (cheaper to construct, cacheable). A smalltalker nerve twitch might make you want to use inject to optimize this way - using idempotent lambdas where possible. David Vallner --------------enigBCC0175C63B7AE6037D9B452 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFRUEdy6MhrS8astoRAvHQAJ4vZrxPiwKHSoZ/wmq8+9ENz7kqqgCeP7uu hGJQxPjaiEr/GwuDzR4eJ3A= =2SOa -----END PGP SIGNATURE----- --------------enigBCC0175C63B7AE6037D9B452--