authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-22 15:45:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-23 01:16:44-08:00
log256c5934bfc19d3b8a1cf01bc07c9ad86a6c6524
treec2829b003b5e11041c2b545e0084f10a4ecaaf22
parent30f15e3afe38afb6b8c1a378c326d29d2ebab378

std.tar: remove abuse of inline fn

In general, any `inline fn` should document why it is using `inline` because the rule of thumb is: don't use inline.

1 files changed, 7 insertions(+), 7 deletions(-)

lib/std/tar.zig+7-7
......@@ -299,14 +299,14 @@ fn Iterator(comptime ReaderType: type) type {
299299 return header;
300300 }
301301
302 inline fn readString(self: *Self, size: usize, buffer: []u8) ![]const u8 {
302 fn readString(self: *Self, size: usize, buffer: []u8) ![]const u8 {
303303 if (size > buffer.len) return error.TarCorruptInput;
304304 const buf = buffer[0..size];
305305 try self.reader.readNoEof(buf);
306306 return nullStr(buf);
307307 }
308308
309 inline fn initFile(self: *Self) void {
309 fn initFile(self: *Self) void {
310310 self.file = File{
311311 .name = self.file_name_buffer[0..0],
312312 .link_name = self.link_name_buffer[0..0],
......@@ -318,7 +318,7 @@ fn Iterator(comptime ReaderType: type) type {
318318 }
319319
320320 // Number of padding bytes in the last file block.
321 inline fn blockPadding(size: u64) usize {
321 fn blockPadding(size: u64) usize {
322322 const block_rounded = std.mem.alignForward(u64, size, Header.SIZE); // size rounded to te block boundary
323323 return @intCast(block_rounded - size);
324324 }
......@@ -498,22 +498,22 @@ fn PaxIterator(comptime ReaderType: type) type {
498498 return null;
499499 }
500500
501 inline fn readUntil(self: *Self, delimiter: u8) ![]const u8 {
501 fn readUntil(self: *Self, delimiter: u8) ![]const u8 {
502502 var fbs = std.io.fixedBufferStream(&self.scratch);
503503 try self.reader.streamUntilDelimiter(fbs.writer(), delimiter, null);
504504 return fbs.getWritten();
505505 }
506506
507 inline fn eql(a: []const u8, b: []const u8) bool {
507 fn eql(a: []const u8, b: []const u8) bool {
508508 return std.mem.eql(u8, a, b);
509509 }
510510
511 inline fn hasNull(str: []const u8) bool {
511 fn hasNull(str: []const u8) bool {
512512 return (std.mem.indexOfScalar(u8, str, 0)) != null;
513513 }
514514
515515 // Checks that each record ends with new line.
516 inline fn validateAttributeEnding(reader: ReaderType) !void {
516 fn validateAttributeEnding(reader: ReaderType) !void {
517517 if (try reader.readByte() != '\n') return error.PaxInvalidAttributeEnd;
518518 }
519519 };