From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/9] msgtime: simplify msg_timestamp and msg_datestamp
Date: Wed, 11 Oct 2023 07:20:52 +0000 [thread overview]
Message-ID: <20231011072057.758022-5-e@80x24.org> (raw)
In-Reply-To: <20231011072057.758022-1-e@80x24.org>
We don't need multiple return points nor multiple time_response
calls in either function.
---
lib/PublicInbox/MsgTime.pm | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm
index 58b0deae..bbc9a007 100644
--- a/lib/PublicInbox/MsgTime.pm
+++ b/lib/PublicInbox/MsgTime.pm
@@ -157,20 +157,16 @@ sub msg_date_only ($) {
# Favors Received header for sorting globally
sub msg_timestamp ($;$) {
- my ($hdr, $fallback) = @_; # PublicInbox::Eml
- my $ret;
- $ret = msg_received_at($hdr) and return time_response($ret);
- $ret = msg_date_only($hdr) and return time_response($ret);
- time_response([ $fallback // time, '+0000' ]);
+ my ($eml, $fallback) = @_;
+ time_response(msg_received_at($eml) // msg_date_only($eml) //
+ [ $fallback // time, '+0000' ]);
}
# Favors the Date: header for display and sorting within a thread
sub msg_datestamp ($;$) {
- my ($hdr, $fallback) = @_; # PublicInbox::Eml
- my $ret;
- $ret = msg_date_only($hdr) and return time_response($ret);
- $ret = msg_received_at($hdr) and return time_response($ret);
- time_response([ $fallback // time, '+0000' ]);
+ my ($eml, $fallback) = @_; # PublicInbox::Eml
+ time_response(msg_date_only($eml) // msg_received_at($eml) //
+ [ $fallback // time, '+0000' ]);
}
1;
next prev parent reply other threads:[~2023-10-11 7:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-11 7:20 [PATCH 0/9] lei + import-related updates Eric Wong
2023-10-11 7:20 ` [PATCH 1/9] lei rediff: use ProcessIO for --drq support Eric Wong
2023-10-11 7:20 ` [PATCH 2/9] lei_xsearch: improve curl progress reporting Eric Wong
2023-10-11 7:20 ` [PATCH 3/9] msgtime: quiet warnings we can do nothing about Eric Wong
2023-10-11 7:20 ` Eric Wong [this message]
2023-10-11 7:20 ` [PATCH 5/9] treewide: consolidate "From " line removal Eric Wong
2023-10-11 7:20 ` [PATCH 6/9] import: switch to Unix stream socket for fast-import Eric Wong
2023-10-11 7:20 ` [PATCH 7/9] import: cat_blob is a no-op w/o live fast-import Eric Wong
2023-10-11 7:20 ` [PATCH 8/9] lei blob: run cat_blob on lei/store for pending blobs Eric Wong
2023-10-11 7:20 ` [PATCH 9/9] lei import|tag|rm: support --commit-delay=SECONDS Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231011072057.758022-5-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).