# std.ArrayList: add ensureTotalCapacityPrecise and update doc comments · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/f49d42729a22846ec54b6610db415ac8cdaa31db)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: f49d42729a22846ec54b6610db415ac8cdaa31db

Requested commit: f49d42729a22846ec54b6610db415ac8cdaa31db

Commit: f49d42729a22846ec54b6610db415ac8cdaa31db

Tree: cfd5a54c5d1dbaed017511a740fd4f4cf5593cf9

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
std.ArrayList: add ensureTotalCapacityPrecise and update doc comments

initCapacity did and still does use the ensureTotalCapacityPrecise logic because the initial capacity of an ArrayList is not important in terms of how it grows, so allocating a more exact slice up-front allows for saving memory when the array list never exceeds that initial allocation size. There are use cases where this precise capacity is useful outside of the `init` function, though, like in instances where the user does not call the `init` function themselves but otherwise knows that an ArrayList is empty so calling `ensureTotalCapacityPrecise` can give the same memory savings that `initCapacity` would have.

Closes #9775

```

## Parents

- [83dcfd62053a80024b1cb282fddf399a36c9c58e](https://git.cafe/gitcafe/zig/commit/83dcfd62053a80024b1cb282fddf399a36c9c58e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/f49d42729a22846ec54b6610db415ac8cdaa31db?format=markdown)
