]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: minor cleanup of duplicated code
authorKeisuke Kishimoto <keisuke.kishimoto@gmail.com>
Sun, 8 Sep 2019 16:39:46 +0000 (16:39 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 9 Sep 2019 03:11:53 +0000 (03:11 +0000)
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>

src/syscall/timestruct.go

index d17811c1214bf4ec0fc16db5d6847dced96c0334..09be22c971a6d9223840762116f4915c7c54bd27 100644 (file)
@@ -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.