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 {...@@ -299,14 +299,14 @@ fn Iterator(comptime ReaderType: type) type {
299 return header;299 return header;
300 }300 }
301301
302 inline fn readString(self: *Self, size: usize, buffer: []u8) ![]const u8 {302 fn readString(self: *Self, size: usize, buffer: []u8) ![]const u8 {
303 if (size > buffer.len) return error.TarCorruptInput;303 if (size > buffer.len) return error.TarCorruptInput;
304 const buf = buffer[0..size];304 const buf = buffer[0..size];
305 try self.reader.readNoEof(buf);305 try self.reader.readNoEof(buf);
306 return nullStr(buf);306 return nullStr(buf);
307 }307 }
308308
309 inline fn initFile(self: *Self) void {309 fn initFile(self: *Self) void {
310 self.file = File{310 self.file = File{
311 .name = self.file_name_buffer[0..0],311 .name = self.file_name_buffer[0..0],
312 .link_name = self.link_name_buffer[0..0],312 .link_name = self.link_name_buffer[0..0],
...@@ -318,7 +318,7 @@ fn Iterator(comptime ReaderType: type) type {...@@ -318,7 +318,7 @@ fn Iterator(comptime ReaderType: type) type {
318 }318 }
319319
320 // Number of padding bytes in the last file block.320 // Number of padding bytes in the last file block.
321 inline fn blockPadding(size: u64) usize {321 fn blockPadding(size: u64) usize {
322 const block_rounded = std.mem.alignForward(u64, size, Header.SIZE); // size rounded to te block boundary322 const block_rounded = std.mem.alignForward(u64, size, Header.SIZE); // size rounded to te block boundary
323 return @intCast(block_rounded - size);323 return @intCast(block_rounded - size);
324 }324 }
...@@ -498,22 +498,22 @@ fn PaxIterator(comptime ReaderType: type) type {...@@ -498,22 +498,22 @@ fn PaxIterator(comptime ReaderType: type) type {
498 return null;498 return null;
499 }499 }
500500
501 inline fn readUntil(self: *Self, delimiter: u8) ![]const u8 {501 fn readUntil(self: *Self, delimiter: u8) ![]const u8 {
502 var fbs = std.io.fixedBufferStream(&self.scratch);502 var fbs = std.io.fixedBufferStream(&self.scratch);
503 try self.reader.streamUntilDelimiter(fbs.writer(), delimiter, null);503 try self.reader.streamUntilDelimiter(fbs.writer(), delimiter, null);
504 return fbs.getWritten();504 return fbs.getWritten();
505 }505 }
506506
507 inline fn eql(a: []const u8, b: []const u8) bool {507 fn eql(a: []const u8, b: []const u8) bool {
508 return std.mem.eql(u8, a, b);508 return std.mem.eql(u8, a, b);
509 }509 }
510510
511 inline fn hasNull(str: []const u8) bool {511 fn hasNull(str: []const u8) bool {
512 return (std.mem.indexOfScalar(u8, str, 0)) != null;512 return (std.mem.indexOfScalar(u8, str, 0)) != null;
513 }513 }
514514
515 // Checks that each record ends with new line.515 // Checks that each record ends with new line.
516 inline fn validateAttributeEnding(reader: ReaderType) !void {516 fn validateAttributeEnding(reader: ReaderType) !void {
517 if (try reader.readByte() != '\n') return error.PaxInvalidAttributeEnd;517 if (try reader.readByte() != '\n') return error.PaxInvalidAttributeEnd;
518 }518 }
519 };519 };