summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeisuke Kishimoto <keisuke.kishimoto@gmail.com>2019-09-08 16:39:46 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2019-09-09 03:11:53 +0000
commit844e642392e1586e6631aafeda5007f9f0f55145 (patch)
tree70123e60523d412876f2d4c37375283f94618397 /src
parent0efbd1015774a2d894138519f1efcf7704bb2d95 (diff)
downloadgo-git-844e642392e1586e6631aafeda5007f9f0f55145.tar.gz
syscall: minor cleanup of duplicated code
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í <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/syscall/timestruct.go4
1 files 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.