]> Cypherpunks repositories - gostls13.git/commitdiff
time: fix time.Before to reuse t.sec(), u.sec()
authorPaschalis Tsilias <paschalis.tsilias@gmail.com>
Mon, 3 Feb 2020 08:47:41 +0000 (10:47 +0200)
committerIan Lance Taylor <iant@golang.org>
Mon, 16 Mar 2020 20:59:27 +0000 (20:59 +0000)
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>
src/time/time.go

index 5fa09687e9cae87c8889c72d015a505ff8513098..3f632dbc3e3664044174eb4a57fa0c90c564e0aa 100644 (file)
@@ -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.