- 主题:这个办的人气实在是太不足了,请教个问题大家讨论讨论吧
golang的map底层bucket数据结构是个bmap,他包括tophash、topbits、keys、elems、overflow等字段。
但是实际上bmap的结构体定义只有tophash,其他字段都是通过反射填充的。
之前hmap是一个确定的结构体,但是现在看也要弄成和bmap一样通过反射编码了。(没仔细翻具体是哪个版本变成这样的)。
想问问为啥要用这种方式,而不是直接使用一个确定的结构体。
咱啥时候也能像家庭生活、汽车世界那样天天霸榜十大呢。哈哈哈哈哈哈哈哈
--
FROM 111.204.182.*
代码里写了:
NOTE: packing all the keys together and then all the elems together makes the code a bit more complicated than alternating key/elem/key/elem/... but it allows us to eliminate padding which would be needed for, e.g., map[int64]int8.
码农已经很少了,Go的码农更少,上十大是做梦。除非你天天在版上发积分。
【 在 Badluck 的大作中提到: 】
: golang的map底层bucket数据结构是个bmap,他包括tophash、topbits、keys、elems、overflow等字段。
: 但是实际上bmap的结构体定义只有tophash,其他字段都是通过反射填充的。
: 之前hmap是一个确定的结构体,但是现在看也要弄成和bmap一样通过反射编码了。(没仔细翻具体是哪个版本变成这样的)。
: ...................
--
FROM 220.181.41.*
这个注释不是说key和value分开存储是为了减少内存对齐的开销么?
【 在 world 的大作中提到: 】
: 代码里写了:
: NOTE: packing all the keys together and then all the elems together makes the code a bit more complicated than alternating key/elem/key/elem/... but it allows us to eliminate padding which would be needed for, e.g., map[int64]int8.
: 码农已经很少了,Go的码农更少,上十大是做梦。除非你天天在版上发积分。
: ...................
--
FROM 223.72.88.*