aboutsummaryrefslogtreecommitdiff
path: root/src/time
diff options
context:
space:
mode:
authorPaschalis Tsilias <paschalis.tsilias@gmail.com>2020-02-03 10:47:41 +0200
committerIan Lance Taylor <iant@golang.org>2020-03-16 20:59:27 +0000
commitff1eb428654b7815a8fc825f1cc29d6cf72cc2f7 (patch)
treed2f4df42565b8a7a8539f9e73d5243af31177727 /src/time
parent26154f31ad6c801d8bad5ef58df1e9263c6beec7 (diff)
downloadgo-ff1eb428654b7815a8fc825f1cc29d6cf72cc2f7.tar.gz
go-ff1eb428654b7815a8fc825f1cc29d6cf72cc2f7.zip
time: fix time.Before to reuse t.sec(), u.sec()
Fixes #36987 Change-Id: I91ea1a42f75302de5256a22d382ab7f1b307a498 Reviewed-on: https://go-review.googlesource.com/c/go/+/217360 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/time')
-rw-r--r--src/time/time.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/time/time.go b/src/time/time.go
index 5fa09687e9..3f632dbc3e 100644
--- a/src/time/time.go
+++ b/src/time/time.go
@@ -252,7 +252,9 @@ func (t Time) Before(u Time) bool {
if t.wall&u.wall&hasMonotonic != 0 {
return t.ext < u.ext
}
- return t.sec() < u.sec() || t.sec() == u.sec() && t.nsec() < u.nsec()
+ ts := t.sec()
+ us := u.sec()
+ return ts < us || ts == us && t.nsec() < u.nsec()
}
// Equal reports whether t and u represent the same time instant.