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 665BD1F626 for ; Mon, 29 Aug 2022 09:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1661765209; bh=fQb47ZhjNDRPHKaDL0KIRz6mdDXKjqJAYE76EQQr8Ic=; h=From:To:Subject:Date:In-Reply-To:References:From; b=1Xq2GsEyAa8RbDKwGmWJEpa/wb2JzNr7rAEyHbnK8RwtOPeD8ZLWPgCRy0CjCgdE5 Z5gbkfmdEKnMkCl7IW/p8tBjkrX29fImUqFzVmAGL4lb+vc0AzJtKzFU/LVOqzysIs 3aYuWUXvCwRVOzj0Jf88Fa0iQfgIk+Q2cGsMUFGY= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 14/18] solver: early make hints detection more robust Date: Mon, 29 Aug 2022 09:26:43 +0000 Message-Id: <20220829092647.1512215-15-e@80x24.org> In-Reply-To: <20220829092647.1512215-1-e@80x24.org> References: <20220829092647.1512215-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Hints fields can change, so we'll use a simple boolean rather than checking a static count. We'll also short-circuit out reliably regardless of hints when a full OID is given. --- lib/PublicInbox/SolverGit.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 52dfaf3d..1e96d042 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -81,9 +81,8 @@ sub solve_existing ($$) { my $oid_b = $want->{oid_b}; my ($oid_full, $type, $size) = $git->check($oid_b); - # other than {oid_b, try_gits, try_ibxs} - my $have_hints = scalar keys %$want > 3; - if (defined($type) && (!$have_hints || $type eq 'blob')) { + if ($oid_b eq ($oid_full // '') || (defined($type) && +- (!$self->{have_hints} || $type eq 'blob'))) { delete $want->{try_gits}; return [ $git, $oid_full, $type, int($size) ]; # done, success } @@ -683,6 +682,7 @@ sub solve ($$$$$) { $self->{seen_oid} = {}; $self->{tot} = 0; $self->{psgi_env} = $env; + $self->{have_hints} = 1 if scalar keys %$hints; $self->{todo} = [ { %$hints, oid_b => $oid_want } ]; $self->{patches} = []; # [ $di, $di, ... ] $self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] }