Next | Program Repair Shop | 119 |
Related to loop counter variables are Array Length Variables
These are variables whose only purpose is to track the length of an array
But the array already tracks its own length
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 structural
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);
Next | Copyright © 2002 M. J. Dominus |