4:57 Wield Tricks for SmallVector (SmallVector 的怪异的小把戏)
左边:仅仅有缓存 (char Buffer[])
右边:基类看起来像个 vector,但是没有缓存。缓存是通过基类的构造函数传入的。这种模式是非常强大的,因为类型擦除了 N
类型擦除N的好处?跨越接口边界的时候,不用关心这个N
6.27 SmallDenseSet
It is a smalll size optimized set. Unlike std::unordered_set, instead we use open addressing here, an array of buckets, flat in memory. We use quadratic probing (二次探测). The traits class is related to hashing.
8:40 SmallDenseMap
The map uses the same traits class.
For empty and tombstone buckets, don‘t put complete pair into those buckets. Acutually, just put the keys into them (special code).
works way better when the values are really small. 这是最最critical的!这样才有足够高的密度。所以真正的challenges,是优化这些values,使他们足够小。这比有上面那些containers更重要。Containers不难,但是有效的使用好它们需要很多的工作。
14:45 第一个关键的想法是给large objects address identity
address identity: 对象有内在的ID吗?something unique about the object。如果仔细分配,可以借用地址作为ID