remove while loops where a for would be more efficient (#8131)

* remove while loops where a for would be more efficient

* this needs to be a stack copy

* this can use the better loop

* this was translated wrong

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
Meghan Denny
2024-01-13 19:13:54 -08:00
committed by GitHub
parent 56f1e5a362
commit be0896e204
33 changed files with 128 additions and 275 deletions

View File

@@ -288,11 +288,10 @@ pub const MutableString = struct {
pub fn toSocketBuffers(self: *MutableString, comptime count: usize, ranges: anytype) [count]std.os.iovec_const {
var buffers: [count]std.os.iovec_const = undefined;
comptime var i: usize = 0;
inline while (i < count) : (i += 1) {
buffers[i] = .{
.iov_base = self.list.items[ranges[i][0]..ranges[i][1]].ptr,
.iov_len = self.list.items[ranges[i][0]..ranges[i][1]].len,
inline for (&buffers, ranges) |*b, r| {
b.* = .{
.iov_base = self.list.items[r[0]..r[1]].ptr,
.iov_len = self.list.items[r[0]..r[1]].len,
};
}
return buffers;