]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: replace some uses of newarray with newobject for maps
authorMartin Möhrmann <moehrmann@google.com>
Thu, 10 Aug 2017 19:24:51 +0000 (21:24 +0200)
committerMartin Möhrmann <moehrmann@google.com>
Mon, 14 Aug 2017 21:25:02 +0000 (21:25 +0000)
This avoids the never triggered capacity checks in newarray.

Change-Id: Ib72b204adcb9e3fd3ab963defe0cd40e22d5d492
Reviewed-on: https://go-review.googlesource.com/54731
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/hashmap.go
src/runtime/hashmap_fast.go

index d9e5d9620726f4b0ffc89e1e10addc007efb3766..87d0d26cfaa9d469b9188445b094f99c3437b415 100644 (file)
@@ -542,7 +542,7 @@ func mapassign(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer {
        h.flags |= hashWriting
 
        if h.buckets == nil {
-               h.buckets = newarray(t.bucket, 1)
+               h.buckets = newobject(t.bucket) // newarray(t.bucket, 1)
        }
 
 again:
index 18ceee46d82357c35a833ba9a3da7ad242e30538..e7a719d63f73494bcaa0400acc7c3117e8ef9cd9 100644 (file)
@@ -426,7 +426,7 @@ func mapassign_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer {
        h.flags |= hashWriting
 
        if h.buckets == nil {
-               h.buckets = newarray(t.bucket, 1)
+               h.buckets = newobject(t.bucket) // newarray(t.bucket, 1)
        }
 
 again:
@@ -514,7 +514,7 @@ func mapassign_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer {
        h.flags |= hashWriting
 
        if h.buckets == nil {
-               h.buckets = newarray(t.bucket, 1)
+               h.buckets = newobject(t.bucket) // newarray(t.bucket, 1)
        }
 
 again:
@@ -603,7 +603,7 @@ func mapassign_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer {
        h.flags |= hashWriting
 
        if h.buckets == nil {
-               h.buckets = newarray(t.bucket, 1)
+               h.buckets = newobject(t.bucket) // newarray(t.bucket, 1)
        }
 
 again: