From 844e642392e1586e6631aafeda5007f9f0f55145 Mon Sep 17 00:00:00 2001 From: Keisuke Kishimoto Date: Sun, 8 Sep 2019 16:39:46 +0000 Subject: [PATCH] syscall: minor cleanup of duplicated code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Call the Nano methods of Timespec and Timeval in TimespecToNsec and TimevalToNsec respectively, instead of duplicating the implementation. Change-Id: I17551ea54c59c1e45ce472e029c625093a67251a GitHub-Last-Rev: fecf43d163f4ebe72e8bb1d3854d4ad962c08b03 GitHub-Pull-Request: golang/go#33390 Reviewed-on: https://go-review.googlesource.com/c/go/+/188397 Reviewed-by: Daniel Martí Reviewed-by: Brad Fitzpatrick Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot --- src/syscall/timestruct.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syscall/timestruct.go b/src/syscall/timestruct.go index d17811c121..09be22c971 100644 --- a/src/syscall/timestruct.go +++ b/src/syscall/timestruct.go @@ -8,7 +8,7 @@ package syscall // TimespecToNsec converts a Timespec value into a number of // nanoseconds since the Unix epoch. -func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } +func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } // NsecToTimespec takes a number of nanoseconds since the Unix epoch // and returns the corresponding Timespec value. @@ -24,7 +24,7 @@ func NsecToTimespec(nsec int64) Timespec { // TimevalToNsec converts a Timeval value into a number of nanoseconds // since the Unix epoch. -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } +func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } // NsecToTimeval takes a number of nanoseconds since the Unix epoch // and returns the corresponding Timeval value. -- 2.50.0