@@ -564,16 +564,16 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
564564 // TODO: reuse overflow buckets instead of using new ones, if there
565565 // is no iterator using the old buckets. (If !oldIterator.)
566566
567- // xy contains the x and y (low and high) evacuation destinations.
567+ // xy 包含的是移动的目标,x 表示前 (low)半部分,y 表示后( high)半部分
568568 var xy [2 ]evacDst
569569 x := &xy[0 ]
570570 x.b = (*bmap)(add (h.buckets , oldbucket*uintptr (t.bucketsize )))
571571 x.k = add (unsafe.Pointer (x.b ), dataOffset)
572572 x.v = add (x.k , bucketCnt*uintptr (t.keysize ))
573573
574574 if !h.sameSizeGrow () {
575- // Only calculate y pointers if we're growing bigger.
576- // Otherwise GC can see bad pointers.
575+ // 如果 map 大小(hmap.B)增大了,那么我们只计算 y
576+ // 否则 GC 可能会看到损坏的指针
577577 y := &xy[1 ]
578578 y.b = (*bmap)(add (h.buckets , (oldbucket+newbit)*uintptr (t.bucketsize )))
579579 y.k = add (unsafe.Pointer (y.b ), dataOffset)
@@ -685,11 +685,11 @@ func advanceEvacuationMark(h *hmap, t *maptype, newbit uintptr) {
685685 h.nevacuate ++
686686 }
687687 if h.nevacuate == newbit { // newbit == # of oldbuckets
688- // Growing is all done. Free old main bucket array.
688+ // 大小增长全部结束。释放老的 bucket array
689689 h.oldbuckets = nil
690- // Can discard old overflow buckets as well.
691- // If they are still referenced by an iterator,
692- // then the iterator holds a pointers to the slice.
690+ // 同样可以丢弃老的 overflow buckets
691+ // 如果它们还被迭代器所引用的话
692+ // 迭代器会持有一份指向 slice 的指针
693693 if h.extra != nil {
694694 h.extra .oldoverflow = nil
695695 }
0 commit comments