[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:13:46PM +0100, Tony Bowden wrote:
> 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;

Since the keys in the hash are being checked with exists(), that could be:

@Words{@Words} = ();

Ronald

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