stage2: tokenizer: require null terminated source
By requiring the source file to be null-terminated, we avoid extra branching while simplifying the logic at the same time. Running ast-check on a large zig source file (udivmodti4_test.zig), master branch compared to this commit: * 4% faster wall clock * 7% fewer cache misses * 1% fewer branches
This commit is contained in:
@@ -17,7 +17,7 @@ pub const Error = error{ParseError} || Allocator.Error;
|
||||
|
||||
/// Result should be freed with tree.deinit() when there are
|
||||
/// no more references to any of the tokens or nodes.
|
||||
pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree {
|
||||
pub fn parse(gpa: *Allocator, source: [:0]const u8) Allocator.Error!Tree {
|
||||
var tokens = ast.TokenList{};
|
||||
defer tokens.deinit(gpa);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user