summaryrefslogtreecommitdiff
path: root/libgo/go/sync/map.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/sync/map.go')
-rw-r--r--libgo/go/sync/map.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/libgo/go/sync/map.go b/libgo/go/sync/map.go
index c4a0dc4194a..c6aa3088565 100644
--- a/libgo/go/sync/map.go
+++ b/libgo/go/sync/map.go
@@ -167,18 +167,14 @@ func (m *Map) Store(key, value interface{}) {
// If the entry is expunged, tryStore returns false and leaves the entry
// unchanged.
func (e *entry) tryStore(i *interface{}) bool {
- p := atomic.LoadPointer(&e.p)
- if p == expunged {
- return false
- }
for {
- if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(i)) {
- return true
- }
- p = atomic.LoadPointer(&e.p)
+ p := atomic.LoadPointer(&e.p)
if p == expunged {
return false
}
+ if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(i)) {
+ return true
+ }
}
}