]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
msgtime: simplify msg_timestamp and msg_datestamp
authorEric Wong <e@80x24.org>
Wed, 11 Oct 2023 07:20:52 +0000 (07:20 +0000)
committerEric Wong <e@80x24.org>
Wed, 11 Oct 2023 22:10:48 +0000 (22:10 +0000)
We don't need multiple return points nor multiple time_response
calls in either function.

lib/PublicInbox/MsgTime.pm

index 58b0deae8650c178294910b7115ff7e61276ce60..bbc9a00704da4d8014cb8a4c0d6360b6718913be 100644 (file)
@@ -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;