in reply to Foreach Loop Optimization
I don't see anything that would make that big of a difference. I think the problem is elsewhere.
time is a system call. You could save a little speed by calling it once outside the loop.
If /approv/i should actually checking for equality, lc($_) eq 'approv' is 122% faster when the check is true and 28% faster when the check is false.
Comments not related to performance:
$localtime = FormatTime($moduleField[2]) if $moduleField[2]; $localtime = "n/a" unless $moduleField[2];
could be written
$localtime = $moduleField[2] ? FormatTime($moduleField[2]) : "n/a";
Assigning to $_ is dangerous. And it's not even necessary here. Change
$_ = $headers[$dataCount]; if( /approv/i )
to
if( $headers[$dataCount] =~ /approv/i )
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Foreach Loop Optimization
by upallnight (Sexton) on Aug 01, 2007 at 16:11 UTC | |
by ikegami (Patriarch) on Aug 01, 2007 at 16:27 UTC |