about summary refs log tree commit homepage
path: root/lib/PublicInbox/ViewDiff.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-09-10 08:17:18 +0000
committerEric Wong <e@80x24.org>2022-09-10 19:50:47 +0000
commitf32456e0d0f4a7756fcc17c83ccf5b682cb512d9 (patch)
treefee389d9d8a3830717834bba46860b22ed449756 /lib/PublicInbox/ViewDiff.pm
parent3b3ee0a9d98e338c94d8ec90191bbe76faba0d87 (diff)
downloadpublic-inbox-f32456e0d0f4a7756fcc17c83ccf5b682cb512d9.tar.gz
This allows us to focus string concatenations in one place to
allow Perl internal scratchpad optimizations to reuse memory.

Calling Compress::Raw::Zlib::deflate repeatedly proves too
expensive in terms of CPU cycles.
Diffstat (limited to 'lib/PublicInbox/ViewDiff.pm')
-rw-r--r--lib/PublicInbox/ViewDiff.pm14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index 36601910..95b615dc 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -156,7 +156,7 @@ sub diff_header ($$$) {
                 warn "BUG? <$$x> had no ^index line";
         }
         $$x =~ s!^diff --git!anchor1($ctx, $pb) // 'diff --git'!ems;
-        $ctx->zmore(qq(<span\nclass="head">$$x</span>));
+        $ctx->zadd(qq(<span\nclass="head">$$x</span>));
         $dctx;
 }
 
@@ -180,9 +180,9 @@ sub diff_before_or_after ($$) {
                 $$x .= qq(<a href="$ch">changed</a>,);
                 $$x .= ascii_html(pop @x); # $4: insertions/deletions
                 # notes, commit message, etc
-                $ctx->zmore($$x .= $lnk->to_html(pop @x));
+                $ctx->zadd($$x .= $lnk->to_html(pop @x));
         } else {
-                $ctx->zmore($ctx->{-linkify}->to_html($$x));
+                $ctx->zadd($ctx->{-linkify}->to_html($$x));
         }
 }
 
@@ -220,23 +220,23 @@ sub flush_diff ($$) {
                                 if (!defined($dctx)) {
                                         $after .= $s;
                                 } elsif ($s =~ s/\A@@ (\S+) (\S+) @@//) {
-                                        $ctx->zmore(qq(<span\nclass="hunk">) .
+                                        $ctx->zadd(qq(<span\nclass="hunk">) .
                                                 diff_hunk($dctx, $1, $2) .
                                                 $lnk->to_html($s) .
                                                 '</span>');
                                 } elsif ($s =~ /\A\+/) { # $s may be huge
-                                        $ctx->zmore(qq(<span\nclass="add">),
+                                        $ctx->zadd(qq(<span\nclass="add">),
                                                         $lnk->to_html($s),
                                                         '</span>');
                                 } elsif ($s =~ /\A-- $/sm) { # email sig starts
                                         $dctx = undef;
                                         $after .= $s;
                                 } elsif ($s =~ /\A-/) { # $s may be huge
-                                        $ctx->zmore(qq(<span\nclass="del">),
+                                        $ctx->zadd(qq(<span\nclass="del">),
                                                 $lnk->to_html($s),
                                                 '</span>');
                                 } else { # $s may be huge
-                                        $ctx->zmore($lnk->to_html($s));
+                                        $ctx->zadd($lnk->to_html($s));
                                 }
                         }
                         diff_before_or_after($ctx, \$after) if !$dctx;