in reply to Structure slogging: do my homework! :)
This probably is not as efficient as it gets, but you can always get rid of temp vars by replacing one of your for loops with a map:
Ok, it looks nicer . . . let's check some benchmarks...foreach my $k (keys %columns) { $columns{$k} = [ map { $columns{$k}->[$_] } @si ] }
UPDATE!!!
use jmcnamara's solution - it's faster:
Benchmark: timing 30000 iterations of clintp, jeffa, jmcnamara... clintp: 5 wallclock secs ( 4.29 usr + 0.10 sys = 4.39 CPU) @ 6833.71/s (n=30000) jeffa: 3 wallclock secs ( 3.12 usr + 0.01 sys = 3.13 CPU) @ 9584.66/s (n=30000) jmcnamara: 2 wallclock secs ( 2.18 usr + 0.01 sys = 2.19 CPU) @ 13698.63/s (n=30000)
jeffa
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Structure slogging: do my homework! :)
by clintp (Curate) on Nov 01, 2001 at 20:33 UTC |