From 3b7cdd9173bd0d74fc181b05c02d90b320d621ae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 11 Oct 2023 07:20:52 +0000 Subject: msgtime: simplify msg_timestamp and msg_datestamp 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(-) (limited to 'lib/PublicInbox/MsgTime.pm') 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; -- cgit v1.2.3-24-ge0c7