From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,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.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 68C6D1F87C for ; Thu, 30 Nov 2023 11:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1701344471; bh=qzWjIo9rjnVi0kpXihWzWAClWP6ebn9/gfNo7HZ85Ek=; h=From:To:Subject:Date:In-Reply-To:References:From; b=H5ZtlEwCHlKbHu480f1HboC0Xm101mqdXfaADhVrpulSUv91XcMINqs+4sPPlQUpH 0lP7czOE1JrRyD7xoZDKjsHvYr3eL6AR8EEkHl96ptdE/OssrL80PmOm+3/sLBoAqA KuZcqj6xHDG/NzUa7x0uVbi2/ULP3IG3BimJZ4tw= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 14/15] inbox: shrink data structures for publicinbox.*.hide Date: Thu, 30 Nov 2023 11:41:07 +0000 Message-ID: <20231130114109.2577708-15-e@80x24.org> In-Reply-To: <20231130114109.2577708-1-e@80x24.org> References: <20231130114109.2577708-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We no longer vivify the intermediate $ibx->{-hide} hashref, instead we use $ibx->{-hide_$KEY} directly. This avoids an intermediate hashref and extra hash table lookups. --- lib/PublicInbox/CodeSearch.pm | 2 +- lib/PublicInbox/Inbox.pm | 8 ++------ lib/PublicInbox/WwwListing.pm | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/CodeSearch.pm b/lib/PublicInbox/CodeSearch.pm index 208f7528..f4694686 100644 --- a/lib/PublicInbox/CodeSearch.pm +++ b/lib/PublicInbox/CodeSearch.pm @@ -328,7 +328,7 @@ EOM if (my $git = $dir2cr{$_}) { $ibx_p2g{$_} = $git; $ibx2self = 1; - $ibx->{-hide}->{www} or + $ibx->{-hide_www} or push @{$git->{ibx_score}}, [ $nr, $ibx->{name} ]; push @$gits, $git; diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 7af0ad90..dd689221 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -70,12 +70,8 @@ sub new { delete $opts->{feedmax}; } # allow any combination of multi-line or comma-delimited hide entries - my $hide = {}; - if (defined(my $h = $opts->{hide})) { - foreach my $v (@$h) { - $hide->{$_} = 1 foreach (split(/\s*,\s*/, $v)); - } - $opts->{-hide} = $hide; + for $v (@{delete($opts->{hide}) // []}) { + $opts->{-'hide_'.$_} = 1 for split(/\s*,\s*/, $v); } bless $opts, $class; } diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index e3d2e84c..2d6c74da 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -79,7 +79,7 @@ sub hide_key { 'www' } sub hide_inbox { my ($ctx, $ibx, $re) = @_; - $ibx->{-hide}->{$ctx->hide_key} || + $ibx->{'-hide_'.$ctx->hide_key} || !grep(/$re/, @{$ibx->{url} // $ctx->{-name_is_url} // []}) }