* Ronald J Kimball (rjk@linguist.dartmouth.edu) [991001 10:37]: > On Fri, Oct 01, 1999 at 09:55:44AM -0400, John Porter wrote: > > lr@hpl.hp.com wrote: > > > > > > > foreach $site (sort keys %sites) { > > > > #... > > > > my $mindshare = mindshare(...); > > > > $shares{$site} = $mindshare; > > > > } > > > > > > Why an explicit (slow) loop? > > > > > > my %shares; > > > @shares{keys %sites} = map mindshare($_) => values %sites; > > > > I realize the argument has shifted to performance... but, larry, > > what you wrote isn't the same as the original. > > I think you should have written > > > > my %shares; > > @shares{keys %sites} = map mindshare($_) => keys %sites; > > > > Note the source for the map is keys %sites, not values %sites. > > > > And I think this shifts the entire direction of how this code > > can be optimized. > > > > Neither code is the same as the original. Code the same as the original > cannot be benchmarked, because the original code is not complete! > > my $mindshare = mindshare(...); > > We don't know what the arguments to mindshare() are. O.k., now you're the one who's being perticlar. :-) It's pretty obvious that the arguments would include each key from %sites. > Clearly, the loop is > where optimization has to be focused. Right; and that's where suggested optimizations *have* been focused. -- John Porter ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe