]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
inbox: shrink data structures for publicinbox.*.hide
authorEric Wong <e@80x24.org>
Thu, 30 Nov 2023 11:41:07 +0000 (11:41 +0000)
committerEric Wong <e@80x24.org>
Thu, 30 Nov 2023 21:37:00 +0000 (21:37 +0000)
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
lib/PublicInbox/Inbox.pm
lib/PublicInbox/WwwListing.pm

index 208f75287641c8e5bb3d2094bce328716f6e93c8..f4694686dd373087dcb6fb5eb3ddd44e81e4c8a7 100644 (file)
@@ -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;
index 7af0ad90468f5f1004e7528137af83a63b718e28..dd689221146ad53b73a3d3b770b37070e0f3d1f7 100644 (file)
@@ -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;
 }
index e3d2e84c5f4216367995e05f52534198d9917ee4..2d6c74dafc527f821c2f4d553a0268b25c11217d 100644 (file)
@@ -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} // []})
 }