# Optimize Allocator functions to create less duplicate code for similar types \(\#16332\) · gitcafe/zig

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

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

Visibility: public

Requested revision: 49ac816e3683def5d14d6f8415d80413ecb43e4c

Requested commit: 49ac816e3683def5d14d6f8415d80413ecb43e4c

Commit: 49ac816e3683def5d14d6f8415d80413ecb43e4c

Tree: d1111a8019b7e1cb4c6a0f28158d3806126ec5d3

Author: IntegratedQuantum

Committer: GitHub

## Message

```
Optimize Allocator functions to create less duplicate code for similar types (#16332)

* Move functionality from generic functions that doesn't depend on the type into a function that only depends on comptime alignment.

This reduces comptime code duplication because e.g. `alloc(u32, )` and `alloc(i32, )` now use the same function `allocWithFoo(4, 4, )` under the hood.
```

## Parents

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

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