Commit 84a5a9b5 authored by Rob Pike's avatar Rob Pike

time: avoid data race in abs

Fixes #3967.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6460115
parent 2eb6a16e
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment