USe maxLineLength throughout
This commit is contained in:
parent
a52156a686
commit
dfc8884406
1 changed files with 5 additions and 5 deletions
10
src/main.zig
10
src/main.zig
|
@ -17,8 +17,10 @@ const version = "0.1.0";
|
||||||
// step 4: [ ] skip a number of matching lines
|
// step 4: [ ] skip a number of matching lines
|
||||||
// step 5: [ ] skip a number of tokens
|
// step 5: [ ] skip a number of tokens
|
||||||
|
|
||||||
|
const maxLineLength = 4096;
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
var buffer: [4096]u8 = undefined;
|
var buffer: [maxLineLength]u8 = undefined;
|
||||||
var fba = heap.FixedBufferAllocator.init(&buffer);
|
var fba = heap.FixedBufferAllocator.init(&buffer);
|
||||||
const allocator = fba.allocator();
|
const allocator = fba.allocator();
|
||||||
|
|
||||||
|
@ -95,8 +97,6 @@ fn parseArgs() !Config {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxLineLength = 4096;
|
|
||||||
|
|
||||||
fn dumpInput(config: Config, in: fs.File, out: fs.File, allocator: mem.Allocator) !void {
|
fn dumpInput(config: Config, in: fs.File, out: fs.File, allocator: mem.Allocator) !void {
|
||||||
const writer = out.writer();
|
const writer = out.writer();
|
||||||
const reader = in.reader();
|
const reader = in.reader();
|
||||||
|
@ -182,7 +182,7 @@ test "pumpIterator" {
|
||||||
}
|
}
|
||||||
|
|
||||||
const LineIterator = struct {
|
const LineIterator = struct {
|
||||||
reader: io.BufferedReader(4096, fs.File.Reader),
|
reader: io.BufferedReader(maxLineLength, fs.File.Reader),
|
||||||
delimiter: u8,
|
delimiter: u8,
|
||||||
allocator: mem.Allocator,
|
allocator: mem.Allocator,
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ const LineIterator = struct {
|
||||||
|
|
||||||
/// Caller owns returned memory
|
/// Caller owns returned memory
|
||||||
pub fn next(self: *Self) ?[]u8 {
|
pub fn next(self: *Self) ?[]u8 {
|
||||||
return self.reader.reader().readUntilDelimiterOrEofAlloc(self.allocator, self.delimiter, 4096) catch null;
|
return self.reader.reader().readUntilDelimiterOrEofAlloc(self.allocator, self.delimiter, maxLineLength) catch null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue