From c28f8cd2b51d7a3fcdd5aedf007ff1fd79599891 Mon Sep 17 00:00:00 2001 From: baycore Date: Wed, 22 Oct 2025 18:15:11 +0800 Subject: [PATCH 1/4] Refactor IsZero method to use wall and ext fields When t.sec() == 0 && t.nsec() == 0 is true, t.wall == 0 && t.ext == 0 must also be true. These two are completely equivalent, and using the latter instead of the former will be more efficient. --- src/time/time.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/time/time.go b/src/time/time.go index cf9abc7196f9cf..2aaf09279704c1 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -260,7 +260,7 @@ func (t *Time) mono() int64 { // IsZero reports whether t represents the zero time instant, // January 1, year 1, 00:00:00 UTC. func (t Time) IsZero() bool { - return t.sec() == 0 && t.nsec() == 0 + return t.wall == 0 && t.ext == 0 } // After reports whether the time instant t is after u. From 49771b9ab8c7d6328842aebf5c8f4d895eec5f66 Mon Sep 17 00:00:00 2001 From: baycore Date: Fri, 24 Oct 2025 14:53:36 +0800 Subject: [PATCH 2/4] Clarify IsZero method with additional comment Add comment to IsZero method for clarity --- src/time/time.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/time/time.go b/src/time/time.go index 2aaf09279704c1..7e2f6160eca50a 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -259,6 +259,7 @@ func (t *Time) mono() int64 { // IsZero reports whether t represents the zero time instant, // January 1, year 1, 00:00:00 UTC. +// Equivalent to t.sec() == 0 && t.nsec() == 0 func (t Time) IsZero() bool { return t.wall == 0 && t.ext == 0 } From 269b1b84ff5e907fca41949178e47d6841af7dac Mon Sep 17 00:00:00 2001 From: baycore Date: Mon, 27 Oct 2025 10:08:56 +0800 Subject: [PATCH 3/4] Enhance IsZero method comments for clarity and efficiency Improve efficiency of IsZero method by providing additional context in comments. --- src/time/time.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/time/time.go b/src/time/time.go index 7e2f6160eca50a..b4537a09086e41 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -259,8 +259,11 @@ func (t *Time) mono() int64 { // IsZero reports whether t represents the zero time instant, // January 1, year 1, 00:00:00 UTC. -// Equivalent to t.sec() == 0 && t.nsec() == 0 func (t Time) IsZero() bool { + // If hasMonotonic is set in t.wall, then the time can't be before 1885, so it can't be the year 1. + // If hasMonotonic is zero, then all the bits in wall other than the nanoseconds field should be 0. + // So if there are no nanoseconds then t.wall == 0, and if there are no seconds then t.ext == 0. + // This is equivalent to t.sec() == 0 && t.nsec() == 0, but is more efficient. return t.wall == 0 && t.ext == 0 } From 4a91948413079047cb6c382ed29844f456f3064d Mon Sep 17 00:00:00 2001 From: baycore Date: Mon, 27 Oct 2025 12:36:15 +0800 Subject: [PATCH 4/4] Rewrite comments in IsZero function for clarity --- src/time/time.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/time/time.go b/src/time/time.go index b4537a09086e41..32a1ce4307d148 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -260,9 +260,9 @@ func (t *Time) mono() int64 { // IsZero reports whether t represents the zero time instant, // January 1, year 1, 00:00:00 UTC. func (t Time) IsZero() bool { - // If hasMonotonic is set in t.wall, then the time can't be before 1885, so it can't be the year 1. - // If hasMonotonic is zero, then all the bits in wall other than the nanoseconds field should be 0. - // So if there are no nanoseconds then t.wall == 0, and if there are no seconds then t.ext == 0. + // If hasMonotonic is set in t.wall, then the time can't be before 1885, so it can't be the year 1. + // If hasMonotonic is zero, then all the bits in wall other than the nanoseconds field should be 0. + // So if there are no nanoseconds then t.wall == 0, and if there are no seconds then t.ext == 0. // This is equivalent to t.sec() == 0 && t.nsec() == 0, but is more efficient. return t.wall == 0 && t.ext == 0 }