From 7e9a8546e4b6a703b102c074e5620390550d9706 Mon Sep 17 00:00:00 2001 From: Kunpei Sakai Date: Mon, 26 Feb 2018 20:00:51 +0900 Subject: [PATCH] time: avoid unnecessary type conversions Change-Id: Ic318c25b21298ec123eb27c814c79f637887713c Reviewed-on: https://go-review.googlesource.com/97135 Run-TryBot: Kunpei Sakai TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/time/time.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/time/time.go b/src/time/time.go index 93909682f5..5e357e1aec 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -158,7 +158,7 @@ func (t *Time) sec() int64 { if t.wall&hasMonotonic != 0 { return wallToInternal + int64(t.wall<<1>>(nsecShift+1)) } - return int64(t.ext) + return t.ext } // unixSec returns the time's seconds since Jan 1 1970 (Unix time). @@ -205,7 +205,7 @@ func (t *Time) stripMono() { // setMono is a no-op. func (t *Time) setMono(m int64) { if t.wall&hasMonotonic == 0 { - sec := int64(t.ext) + sec := t.ext if sec < minWall || maxWall < sec { return } @@ -855,7 +855,7 @@ func (t Time) Add(d Duration) Time { t.addSec(dsec) if t.wall&hasMonotonic != 0 { te := t.ext + int64(d) - if d < 0 && te > int64(t.ext) || d > 0 && te < int64(t.ext) { + if d < 0 && te > t.ext || d > 0 && te < t.ext { // Monotonic clock reading now out of range; degrade to wall-only. t.stripMono() } else { @@ -871,8 +871,8 @@ func (t Time) Add(d Duration) Time { // To compute t-d for a duration d, use t.Add(-d). func (t Time) Sub(u Time) Duration { if t.wall&u.wall&hasMonotonic != 0 { - te := int64(t.ext) - ue := int64(u.ext) + te := t.ext + ue := u.ext d := Duration(te - ue) if d < 0 && te > ue { return maxDuration // t - u is positive out of range -- 2.48.1