diff options
author | zachir <zachir@librem.one> | 2024-03-26 00:52:29 -0500 |
---|---|---|
committer | zachir <zachir@librem.one> | 2024-03-26 00:52:29 -0500 |
commit | e6b631584a4470ac8edd3c1898981367e2ffe4e9 (patch) | |
tree | bb1dbdf3ed9e3ef12d46f03151a93a31ff890114 /src/main.zig | |
parent | d033325a449f752588ed459dba57da6742f79676 (diff) |
Remove two unnecessary variables
Removing the entire body []u8 and the whole_number usize, as both of
these are actually unnecessary.
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig index e611aac..1e62272 100644 --- a/src/main.zig +++ b/src/main.zig @@ -43,8 +43,7 @@ const buffer_limit = 1 << 21; /// file.stat() will return a StatError /// file.readAll() will return a ReadError fn readFiles(target: []const u8, buffer: []u8) !usize { - const whole_buffer = max_path_bytes * 2; - var fba_buffer: [whole_buffer]u8 = undefined; + var fba_buffer: [max_path_bytes * 2]u8 = undefined; var fba = std.heap.FixedBufferAllocator.init(&fba_buffer); const allocator = fba.allocator(); @@ -173,9 +172,7 @@ fn handleRequest(response: *std.http.Server.Response) !void { } } } - // Create a []u8 that is exactly the intended size and no larger - const body = read[0..size]; - log.info("{}", .{body.len}); + log.info("{}", .{size}); // Check if the request target contains "?chunked" if (std.mem.indexOf(u8, response.request.target, "?chunked") != null) { response.transfer_encoding = .chunked; @@ -185,7 +182,7 @@ fn handleRequest(response: *std.http.Server.Response) !void { // Transmit the response try response.do(); if (response.request.method != .HEAD) { - try response.writeAll(body); + _ = try response.write(read[0..size]); try response.finish(); } } else { |