From f32456e0d0f4a7756fcc17c83ccf5b682cb512d9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 10 Sep 2022 08:17:18 +0000 Subject: www: switch to zadd for the majority of buffering 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. --- lib/PublicInbox/ViewDiff.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/ViewDiff.pm') 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($$x)); + $ctx->zadd(qq($$x)); $dctx; } @@ -180,9 +180,9 @@ sub diff_before_or_after ($$) { $$x .= qq(changed,); $$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() . + $ctx->zadd(qq() . diff_hunk($dctx, $1, $2) . $lnk->to_html($s) . ''); } elsif ($s =~ /\A\+/) { # $s may be huge - $ctx->zmore(qq(), + $ctx->zadd(qq(), $lnk->to_html($s), ''); } elsif ($s =~ /\A-- $/sm) { # email sig starts $dctx = undef; $after .= $s; } elsif ($s =~ /\A-/) { # $s may be huge - $ctx->zmore(qq(), + $ctx->zadd(qq(), $lnk->to_html($s), ''); } 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; -- cgit v1.2.3-24-ge0c7