zig
zig copied to clipboard
Rename `simd.suggestVectorSize` to clarify intent and fix related segfault
Closes #18296.
The first commit fixes the segfault in mem.indexOfSentinel.
The second renames suggestVectorSize to suggestVectorLength and makes the former a compile error. The function returns the vector length (as in, the number of elements), not the size in bytes of the entire vector or the bit size of individual elements. This distinction is important and some usages of the function in the stdlib operated under these incorrect assumptions.
I combed through nearby local variables and updated the names of them where the distinction was relevant.
Let me know if you would rather have the bug fix and the updated function names be two separate change sets.
Wouldn't suggestVectorLen fit better here to parallel .len on arrays and slices?
Wouldn't
suggestVectorLenfit better here to parallel.lenon arrays and slices?
No opinion, but I should add I went with "length" because that file already had a function named vectorLength a few lines down.
https://github.com/ziglang/zig/blob/4ae4ded16488cd70ef4473889f343c27373045de/lib/std/simd.zig#L80-L86
Another excellent @castholm patch.