[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Love & Hate shenanigans



On Thu, Mar 29, 2001 at 02:49:21PM +0200, Sven Neuhaus wrote:
> Also interesting: Converting the large array to a hash is very slow with
> map and fast with foreach:

> #%Words = map { $_ => 1 } @Words; # takes ages?!
> foreach (@Words) { $Words{$_} = 1 } # fast

Should be even faster still with a hash slice ...

@Words{@Words} = (1) x @words;

[Haven't benchmarked in this case, but have done so recently when trying
to rewrite some of the Exporter ...]

Tony
--
--------------------------------------------------------------------------
 Tony Bowden | tony@tmtm.com | http://www.tmtm.com/
                 sheep-boy, duck-call, swan-song, idiot son of Donkey Kong
--------------------------------------------------------------------------

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe