]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: speed up /$INBOX/ landing page by 0.5-1.0%
authorEric Wong <e@80x24.org>
Mon, 29 Aug 2022 09:26:37 +0000 (09:26 +0000)
committerEric Wong <e@80x24.org>
Mon, 29 Aug 2022 19:05:48 +0000 (19:05 +0000)
Array lookups and extra arithmetic in Perl is slower than
bumping the internal array offset inside the interpreter.
Fwiw, using: my ($level, $subj) = splice(@extra, 0, 2)
did not result in a performance improvement.

lib/PublicInbox/View.pm

index 5fbdd1fa88cbd9aca73deca28c3b0cb5a9f75552..9846fa4779c6286611bae99301cd68b39b4c5e15 100644 (file)
@@ -1188,9 +1188,9 @@ sub dump_topics {
 
                my $s = "<a\nhref=\"$href/T/$anchor\">$top_subj</a>\n" .
                        " $ds UTC $n\n";
-               for (my $i = 0; $i < scalar(@extra); $i += 2) {
-                       my $level = $extra[$i];
-                       my $subj = $extra[$i + 1]; # already normalized
+               while (@extra) {
+                       my $level = shift @extra;
+                       my $subj = shift @extra; # already normalized
                        $mid = delete $seen->{$subj};
                        my @subj = split(/ /, $subj);
                        my @next_prev = @subj; # full copy