Skip to content

Commit 882a356

Browse files
korzhaogopherbot
authored andcommitted
time: make time.Until a few nanoseconds faster
This is similar to CL 518336. For #61765. Change-Id: I7c1d92a3b3e2b6c1c0058a2094997d93082ad139 Reviewed-on: https://go-review.googlesource.com/c/go/+/521237 Run-TryBot: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 890a62b commit 882a356

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/time/time.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -939,14 +939,11 @@ func Since(t Time) Duration {
939939
// Until returns the duration until t.
940940
// It is shorthand for t.Sub(time.Now()).
941941
func Until(t Time) Duration {
942-
var now Time
943942
if t.wall&hasMonotonic != 0 {
944943
// Common case optimization: if t has monotonic time, then Sub will use only it.
945-
now = Time{hasMonotonic, runtimeNano() - startNano, nil}
946-
} else {
947-
now = Now()
944+
return subMono(t.ext, runtimeNano()-startNano)
948945
}
949-
return t.Sub(now)
946+
return t.Sub(Now())
950947
}
951948

952949
// AddDate returns the time corresponding to adding the

0 commit comments

Comments
 (0)