parallel: Replacement of many replacementstring is now faster

This commit is contained in:
Ole Tange 2011-07-20 23:42:59 +02:00
parent 4f8b5026ec
commit 43788cb720

View file

@ -3621,14 +3621,15 @@ sub number_of_replacements {
'|'. '|'.
join("|",map {$a=$_;$a=~s/(\W)/\\$1/g; $a} values %Global::replace). join("|",map {$a=$_;$a=~s/(\W)/\\$1/g; $a} values %Global::replace).
")"; ")";
while($cmd =~ s/($replacement_regexp)/\0/o) { my %c = ();
# substitute with \0 to avoid {{}} being interpreted as two {}'s $cmd =~ s/($replacement_regexp)/$c{$1}++;""/ogex;
if(defined $Global::replace_rev{$1}) { for my $k (keys %c) {
$count{$Global::replace_rev{$1}}++; if(defined $Global::replace_rev{$k}) {
$count{$Global::replace_rev{$k}} = $c{$k};
} else { } else {
$count{$1}++; $count{$k} = $c{$k};
} }
$sum++; $sum += $c{$k};
} }
my $number_of_context_groups = 0; my $number_of_context_groups = 0;