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.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF 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 6E8C91F428 for ; Sat, 11 Mar 2023 17:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1678556160; bh=euNyDhAzD1aCR7t6ojLncYMj3EATAyIKh4lqM9jZzRA=; h=From:To:Subject:Date:From; b=2Vt8LPLAur04Wh2vCHdkhcx0y/oWjed3B1/qj5KYOfBbdqRcCZ1Bz25SrYrkyu51R v5msWn6Y8kudn6jHc7K2jo2xczMyYT8fWmB54Mxq7VrRhAvMzF1QbsoSY4K4fFiDzf 5Fzv+dxpZpMi94X5czKk6YUUP8TuyWR+4JQasNPw= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei_dedupe: simplify smsg_hash sub Date: Sat, 11 Mar 2023 17:36:00 +0000 Message-Id: <20230311173600.2100687-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can just use the sha256() sub instead of dealing with the OO interface for a small string. --- lib/PublicInbox/LeiDedupe.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/LeiDedupe.pm b/lib/PublicInbox/LeiDedupe.pm index 22864508..86cd8490 100644 --- a/lib/PublicInbox/LeiDedupe.pm +++ b/lib/PublicInbox/LeiDedupe.pm @@ -1,10 +1,9 @@ # Copyright (C) all contributors # License: AGPL-3.0+ package PublicInbox::LeiDedupe; -use strict; -use v5.10.1; +use v5.12; use PublicInbox::ContentHash qw(content_hash git_sha); -use PublicInbox::SHA (); +use PublicInbox::SHA qw(sha256); # n.b. mutt sets most of these headers not sure about Bytes our @OID_IGNORE = qw(Status X-Status Content-Length Lines Bytes); @@ -30,11 +29,9 @@ sub _oidbin ($) { defined($_[0]) ? pack('H*', $_[0]) : undef } sub smsg_hash ($) { my ($smsg) = @_; - my $dig = PublicInbox::SHA->new(256); my $x = join("\0", @$smsg{qw(from to cc ds subject references mid)}); utf8::encode($x); - $dig->add($x); - $dig->digest; + sha256($x); } # the paranoid option