From a66a2eddda8ffbb7679f4ef80dba7c7d377cda84 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 29 Aug 2022 09:26:37 +0000 Subject: [PATCH] view: speed up /$INBOX/ landing page by 0.5-1.0% 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 5fbdd1fa..9846fa47 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -1188,9 +1188,9 @@ sub dump_topics { my $s = "$top_subj\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 -- 2.48.1