From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 632171F628 for ; Sat, 10 Sep 2022 08:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662797934; bh=ApZ1Xn0C2/Aqf8I/xcP1CvezVHsbS3fC+R2bVVNXVzM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qxT/zbpZVm20xghEQHa6HpHxUAvnkMC419hs8PZuHpArZN8tCHXqYs4pDU9Xhv8no kwbyTT7cBN9ts8P4nsQUACk5m+CupTUB0X1BtKG7fnBExhoSxNRIAa8B6eqDV/G0bB +nENP/1qlNNPXYsH/To2+NbIm6BjJLlQPHI9YABY= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 15/38] view: reduce subroutine calls for submsg_hdr Date: Sat, 10 Sep 2022 08:17:06 +0000 Message-Id: <20220910081729.2011934-16-e@80x24.org> In-Reply-To: <20220910081729.2011934-1-e@80x24.org> References: <20220910081729.2011934-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Favor fewer, yet more expensive operations than many smaller ones. While we're still directly manipulating ctx->{obuf} after this, this change makes it easier for us to avoid doing so in the future. --- lib/PublicInbox/View.pm | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 0b67d92f..1b55fe77 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -508,17 +508,12 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback sub submsg_hdr ($$) { my ($ctx, $eml) = @_; - my $obfs_ibx = $ctx->{-obfs_ibx}; - my $rv = $ctx->{obuf}; - $$rv .= "\n"; + my $s = "\n"; for my $h (qw(From To Cc Subject Date Message-ID X-Alt-Message-ID)) { - my @v = $eml->header($h); - for my $v (@v) { - obfuscate_addrs($obfs_ibx, $v) if $obfs_ibx; - $v = ascii_html($v); - $$rv .= "$h: $v\n"; - } + $s .= "$h: $_\n" for $eml->header($h); } + obfuscate_addrs($ctx->{-obfs_ibx}, $s) if $ctx->{-obfs_ibx}; + ascii_html($s); } sub attach_link ($$$$;$) { @@ -559,7 +554,7 @@ EOF $$rv .= ($desc eq '') ? "$ts --]" : "$desc --]\n[-- $ts --]"; $$rv .= "\n"; - submsg_hdr($ctx, $part) if $part->{is_submsg}; + $$rv .= submsg_hdr($ctx, $part) if $part->{is_submsg}; undef; } @@ -578,7 +573,7 @@ sub add_text_body { # callback for each_part my $rv = $ctx->{obuf}; if ($part->{is_submsg}) { - submsg_hdr($ctx, $part); + $$rv .= submsg_hdr($ctx, $part); $$rv .= "\n"; }