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.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 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 8D84D2032D for ; Tue, 12 Mar 2019 04:00:46 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 03/13] viewvcs: match 8000-byte lookup for git Date: Tue, 12 Mar 2019 04:00:36 +0000 Message-Id: <20190312040046.4619-4-e@80x24.org> In-Reply-To: <20190312040046.4619-1-e@80x24.org> References: <20190312040046.4619-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No need to scan the entire string, but prefer to match git behavior. This might be faster if/when Perl can create substrings efficiently using CoW. Fix a 80-column violation while we're at it. --- lib/PublicInbox/ViewVCS.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 4a97b9a..b90cd8c 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -131,14 +131,14 @@ sub solve_result { return html_page($ctx, 500, \$log); } - my $binary = index($$blob, "\0") >= 0; + my $bin = index(substr($$blob, 0, $BIN_DETECT), "\0") >= 0; if (defined $fn) { my $h = [ 'Content-Length', $size, 'Content-Type' ]; - push(@$h, ($binary ? 'application/octet-stream' : 'text/plain')); + push(@$h, ($bin ? 'application/octet-stream' : 'text/plain')); return delete($ctx->{-wcb})->([200, $h, [ $$blob ]]); } - if ($binary) { + if ($bin) { $log = "
$oid $type $size bytes (binary)" .
 			" $raw_link
" . $log; return html_page($ctx, 200, \$log); -- EW