https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7616

--- Comment #7 from Henrik Krohns <[email protected]> ---
Just for fun, here are some benchmarks (fastest time) for alternatives I came
up with, running wrap() dozen times through a 40MB mbox. Also verified all had
identical output.

I'm amazed that the 5.14 way is consistently 10% faster. :-D Perhaps
we can return to it when minimum version is raised.

orig 11.53s
    my $len = length ($arr[$pos] =~ s/\t/        /gr);
    if ($pos_mod != 0 && $overflow == 0) {
      $len += length ($arr[$pos+1] =~ s/\t/        /gr);

hege 12.68s
    my $len = length ($arr[$pos]);
    $tabs = $arr[$pos] =~ tr/\t//;
    $len += $tabs*7 if $tabs;
    if ($pos_mod != 0 && $overflow == 0) {
      $len += length($arr[$pos+1]);
      $tabs = $arr[$pos+1] =~ tr/\t//;
      $len += $tabs*7 if $tabs;

bill 12.77s
    my $tmpline = $arr[$pos] ;
    $tmpline =~ s/\t/        /g;
    my $len = length ($tmpline);
    if ($pos_mod != 0 && $overflow == 0) {
      my $tmpnext = $arr[$pos+1] ;
      $tmpnext =~ s/\t/        /g;
      $len += length ($tmpnext);

hege2 13.17s
    my $len = length ($arr[$pos]);
    $len += 7 while ($arr[$pos] =~ /\t/g);
    if ($pos_mod != 0 && $overflow == 0) {
      $len += length ($arr[$pos+1]);
      $len += 7 while ($arr[$pos+1] =~ /\t/g);

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to