in reply to Faster indexing an array
I'll let you do the benchmarking. However, I suspect that using a range-based for loop will be faster than a C-style for loop, because it pushes more work out of Perl and into perl.
push @{ $z->{$y->[$_]} }, $_ for 0 .. $#$y;
If that's still not fast enough, rewrite the alignment algorithm with Inline::C. :) You're currently chasing after possibly halving the runtime of a segment of code that consumes 15% of a tight algorithm. Let's say you could completely optimize out this tranform. That's still only a 15% savings. If, instead, you're able to cut it in half, that's a 7.5% savings overall. Rewrite the entire algorithm in C using Inline::C, and you might be able to shave half off the algorithm's runtime, rather than half off of a small portion of the algorithm's runtime.
Dave
|
|---|