Skip to content

Commit f7b75cd

Browse files
committed
update map
1 parent 326ce47 commit f7b75cd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

map.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,12 @@ done:
358358

359359
赋值的最后一步实际上是编译器额外生成的汇编指令来完成的,可见靠 runtime 有些工作是没有做完的。这里和 go 在函数调用时插入 prologue 和 epilogue 是类似的。编译器和 runtime 配合,才能完成一些复杂的工作。
360360

361+
## 删除
362+
361363
## 扩容
364+
365+
## 其它
366+
367+
针对 32 位、64 位 和 string 类型的 map 元素的访问、赋值、删除、扩容,Go 内部有都有对应的优化函数,比如 mapaccess1 对应有 mapaccess1_fast64,mapaccess1_fast32,mapaccess1_faststr。mapassign 对应有 mapassign_fast64,mapassign_fast32 和 mapassign_faststr。
368+
369+
但这些优化函数长得都差不多,但不知为何官方没有用脚本来做这些优化函数的生成工作。可见有时候 Go team 的复制粘贴功力也是蛮强的。

0 commit comments

Comments
 (0)