user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 2/2] content_digest_dbg: convert to arrayref and limit to lei
  2023-01-29 10:30  5% [PATCH 0/2] allow OpenSSL SHA-(1|256) use if installed Eric Wong
@ 2023-01-29 10:30  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-01-29 10:30 UTC (permalink / raw)
  To: meta

Since it's an extremely small class and not subclassed or
anything, we'll make it even smaller as an arrayref.

We also don't load this for PublicInbox::WWW or anything that
runs in public-facing daemons.
---
 lib/PublicInbox/ContentDigestDbg.pm | 10 ++++++----
 lib/PublicInbox/MailDiff.pm         |  5 +----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/ContentDigestDbg.pm b/lib/PublicInbox/ContentDigestDbg.pm
index 899afbbe..5de0ee8a 100644
--- a/lib/PublicInbox/ContentDigestDbg.pm
+++ b/lib/PublicInbox/ContentDigestDbg.pm
@@ -1,17 +1,19 @@
 # Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+# only loaded in lei
 package PublicInbox::ContentDigestDbg; # cf. PublicInbox::ContentDigest
 use v5.12;
 use Data::Dumper;
 use PublicInbox::SHA;
+$Data::Dumper::Useqq = $Data::Dumper::Terse = 1;
 
-sub new { bless { dig => PublicInbox::SHA->new(256), fh => $_[1] }, __PACKAGE__ }
+sub new { bless [ PublicInbox::SHA->new(256), $_[1] ], __PACKAGE__ }
 
 sub add {
-	$_[0]->{dig}->add($_[1]);
-	print { $_[0]->{fh} } Dumper([split(/^/sm, $_[1])]) or die "print $!";
+	$_[0]->[0]->add($_[1]);
+	print { $_[0]->[1] } Dumper([split(/^/sm, $_[1])]) or die "print $!";
 }
 
-sub hexdigest { $_[0]->{dig}->hexdigest; }
+sub hexdigest { $_[0]->[0]->hexdigest }
 
 1;
diff --git a/lib/PublicInbox/MailDiff.pm b/lib/PublicInbox/MailDiff.pm
index 0ed06f9a..a0ecef9f 100644
--- a/lib/PublicInbox/MailDiff.pm
+++ b/lib/PublicInbox/MailDiff.pm
@@ -4,8 +4,6 @@ package PublicInbox::MailDiff;
 use v5.12;
 use File::Temp 0.19 (); # 0.19 for ->newdir
 use PublicInbox::ContentHash qw(content_digest);
-use PublicInbox::ContentDigestDbg;
-use Data::Dumper ();
 use PublicInbox::MsgIter qw(msg_part_text);
 use PublicInbox::ViewDiff qw(flush_diff);
 use PublicInbox::GitAsyncCat;
@@ -34,12 +32,11 @@ sub dump_eml ($$$) {
 	$eml->each_part(\&write_part, $self);
 
 	return if $self->{ctx}; # don't need content_digest noise in WWW UI
+	require PublicInbox::ContentDigestDbg;
 
 	# XXX is this even useful?  perhaps hide it behind a CLI switch
 	open my $fh, '>', "$dir/content_digest" or die "open: $!";
 	my $dig = PublicInbox::ContentDigestDbg->new($fh);
-	local $Data::Dumper::Useqq = 1;
-	local $Data::Dumper::Terse = 1;
 	content_digest($eml, $dig);
 	print $fh "\n", $dig->hexdigest, "\n" or die "print $!";
 	close $fh or die "close: $!";

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/2] allow OpenSSL SHA-(1|256) use if installed
@ 2023-01-29 10:30  5% Eric Wong
  2023-01-29 10:30  7% ` [PATCH 2/2] content_digest_dbg: convert to arrayref and limit to lei Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-01-29 10:30 UTC (permalink / raw)
  To: meta

OpenSSL has platform-specific asm, and the SHA-256 x86-64
implementation is nearly twice as fast as the portable C
implementation in Perl5.  SHA-1 is a tad faster, too.

We still need to use Digest::SHA in a few places for
->clone to to bifurcate state.

Eric Wong (2):
  use Net::SSLeay (OpenSSL) for SHA-(1|256) if installed
  content_digest_dbg: convert to arrayref and limit to lei

 MANIFEST                            |  2 +
 lib/PublicInbox/ContentDigestDbg.pm | 12 +++---
 lib/PublicInbox/ContentHash.pm      | 11 +++---
 lib/PublicInbox/Fetch.pm            |  4 +-
 lib/PublicInbox/Git.pm              |  4 +-
 lib/PublicInbox/LeiDedupe.pm        |  6 +--
 lib/PublicInbox/LeiMirror.pm        |  2 +-
 lib/PublicInbox/LeiSavedSearch.pm   |  4 +-
 lib/PublicInbox/LeiSucks.pm         | 12 +++---
 lib/PublicInbox/Linkify.pm          |  2 +-
 lib/PublicInbox/MID.pm              |  8 ++--
 lib/PublicInbox/MailDiff.pm         |  5 +--
 lib/PublicInbox/MdirReader.pm       |  4 +-
 lib/PublicInbox/NNTP.pm             |  2 +-
 lib/PublicInbox/SHA.pm              | 58 +++++++++++++++++++++++++++++
 lib/PublicInbox/WwwAtomStream.pm    |  2 +-
 t/clone-coderepo.t                  |  2 +-
 t/httpd-corner.psgi                 |  4 +-
 t/httpd-corner.t                    |  2 +-
 t/ipc.t                             |  6 +--
 t/nntpd.t                           |  4 +-
 t/sha.t                             | 25 +++++++++++++
 t/www_listing.t                     |  2 +-
 xt/git_async_cmp.t                  | 10 ++---
 xt/imapd-validate.t                 |  5 ++-
 xt/nntpd-validate.t                 |  5 ++-
 26 files changed, 145 insertions(+), 58 deletions(-)
 create mode 100644 lib/PublicInbox/SHA.pm
 create mode 100644 t/sha.t

^ permalink raw reply	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-01-29 10:30  5% [PATCH 0/2] allow OpenSSL SHA-(1|256) use if installed Eric Wong
2023-01-29 10:30  7% ` [PATCH 2/2] content_digest_dbg: convert to arrayref and limit to lei Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).