mirror of
https://github.com/golang/go
synced 2024-09-05 16:04:50 +00:00
time: avoid data race in abs
Fixes #3967. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6460115
This commit is contained in:
parent
2eb6a16e16
commit
84a5a9b558
|
@ -241,10 +241,10 @@ func (t Time) IsZero() bool {
|
|||
// It is called when computing a presentation property like Month or Hour.
|
||||
func (t Time) abs() uint64 {
|
||||
l := t.loc
|
||||
if l == nil {
|
||||
l = &utcLoc
|
||||
// Avoid function calls when possible.
|
||||
if l == nil || l == &localLoc {
|
||||
l = l.get()
|
||||
}
|
||||
// Avoid function call if we hit the local time cache.
|
||||
sec := t.sec + internalToUnix
|
||||
if l != &utcLoc {
|
||||
if l.cacheZone != nil && l.cacheStart <= sec && sec < l.cacheEnd {
|
||||
|
|
Loading…
Reference in a new issue