in reply to Re: Re: Reducing Array Interations
in thread Reducing Array Interations

Thats probably because the joined pattern is really overkill in this situation. With the gigantic pattern, we wind up examining each row for each pattern, which requires an inordinate amount of backtracking. If you know that all your tags at the front will be similiar (like the ones in the sample data are) you wind up doing a lot more work than necessary. See if the code below runs any faster...

my @tmp; my %text_remove = map {$_=>1} @text_remove; for (@xlate_data) { s/^(\[TEXT\-\d+\])//; $text_remove{$1} ? $tmp[-1] .= "$_" : push(@tmp,"$1$_"); } @xlate_data = @tmp;

Here, we grab the tag off the front and compare it with a hash of the "special" tags. This should be much quicker than running a gigantic pattern against the data.

-Blake

Replies are listed 'Best First'.
Re: Re: Re: Re: Reducing Array Interations
by THRAK (Monk) on Aug 17, 2001 at 15:53 UTC
    Blake,

    Just a little bit...Time: 0 wallclock secs ( 0.22 usr + 0.00 sys = 0.22 CPU) ;)

    Thank you.

    -THRAK
    www.polarlava.com