☞ | ![]() ![]() |
10 |
For example:
Subject: Re: Sorting is too slow for finding top N keys... - BENCH II Message-Id: <lziu9yy6m2.fsf-@linux_sexi.neuearbeit.de> $pos=0; $array[$pos++]= do { my (@alloc) = ($key, $value, int(rand(1<<16))); \@alloc } while(($key, $value) = each %$href);
$pos here is entirely unnecessary
push @array, do { my (@alloc) = ($key, $value, int(rand(1<<16))); \@alloc } while(($key, $value) = each %$href);
(Here flow control backwards the fix also I.)
while(($key, $value) = each %$href) { push @array, [$key, $value, int(rand(1<<16))]; } # or perhaps @array = map {[$_, $href->{$_}, int(rand(1<<16))]} (keys %$href);
☞ | ![]() |
☞ |