Zig Version
0.17.0-dev.813+2153f8143
Steps to Reproduce, Observed Behavior, and Expected Behavior
std.MultiArrayList.items does a runtime for loop over all the fields.
I'm expecting it to just do "ptr + capacity * constant"
https://godbolt.org/z/5aszWrf3v
This is the issue I'm trying to solve with #32205
The fix is first:
- compute the "offset" of each field at compile time so that it works
- remove calls to
.slice()that do a for loop over all fields to compute the sub-pointers and then materialize all in a struct. The struct may or may not be optimized away.
This impact all the code using std.ArrayHashMap albeit the issue is more limited given there are only up to 3 fields in the internal MultiArrayList.
### Zig Version
0.17.0-dev.813+2153f8143
### Steps to Reproduce, Observed Behavior, and Expected Behavior
std.MultiArrayList.items does a runtime for loop over all the fields.
I'm expecting it to just do "ptr + capacity * constant"
https://godbolt.org/z/5aszWrf3v
This is the issue I'm trying to solve with https://codeberg.org/ziglang/zig/pulls/32205
The fix is first:
- compute the "offset" of each field at compile time so that it works
- remove calls to `.slice()` that do a for loop over all fields to compute the sub-pointers and then materialize all in a struct. The struct may or may not be optimized away.
This impact all the code using std.ArrayHashMap albeit the issue is more limited given there are only up to 3 fields in the internal MultiArrayList.