# Implement clone with initCapacity and appendSliceAssumeCapacity · gitcafe/zig

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

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

Visibility: public

Requested revision: f04007028ff0e9bc34267c5f0f27985917748496

Requested commit: f04007028ff0e9bc34267c5f0f27985917748496

Commit: f04007028ff0e9bc34267c5f0f27985917748496

Tree: 51009b9f5795532daee32ada029ce3dbb4d2a903

Author: John Schmidt

Committer: Veikka Tuominen

## Message

```
Implement clone with initCapacity and appendSliceAssumeCapacity

`ArrayList.ensureTotalCapacityPrecise` uses `Allocator.reallocAtLeast` under
the hood, which can return more than `new_capacity` bytes if `alignment
!= @alignOf(T)`. This implementation of `clone` assures that
the case of `ensureTotalCapacityPrecise` is handled correctly.

Thanks @Vexu and @squeek502 for pointing this out.

```

## Parents

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

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