]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #36766 - nnethercote:hash-span-capacity, r=bluss
authorbors <bors@rust-lang.org>
Mon, 3 Oct 2016 11:25:58 +0000 (04:25 -0700)
committerGitHub <noreply@github.com>
Mon, 3 Oct 2016 11:25:58 +0000 (04:25 -0700)
Clarify HashMap's capacity handling.

HashMap has two notions of "capacity":

- "Usable capacity": the number of elements a hash map can hold without
  resizing. This is the meaning of "capacity" used in HashMap's API,
  e.g. the `with_capacity()` function.

- "Internal capacity": the number of allocated slots. Except for the
  zero case, it is always larger than the usable capacity (because some
  slots must be left empty) and is always a power of two.

HashMap's code is confusing because it does a poor job of
distinguishing these two meanings. I propose using two different terms
for these two concepts. Because "capacity" is already used in HashMap's
API to mean "usable capacity", I will use a different word for "internal
capacity". I propose "span", though I'm happy to consider other names.

1  2 
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/set.rs

Simple merge
Simple merge