diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-06-30 18:03:54 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-07-02 13:27:35 -0700 |
| commit | 3f680abbe2c4d2eeefd0eb73b8af25d1768e6ceb (patch) | |
| tree | 06d67e5aa40cede2686d492445d4d32c2f69a33c /src/translate_c | |
| parent | 8ce880ca753ce95138bf03d956cf363ea2dfde5a (diff) | |
| download | zig-3f680abbe2c4d2eeefd0eb73b8af25d1768e6ceb.tar.gz zig-3f680abbe2c4d2eeefd0eb73b8af25d1768e6ceb.zip | |
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
Diffstat (limited to 'src/translate_c')
| -rw-r--r-- | src/translate_c/ast.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig index 70c8c6559f..cdf8d778b2 100644 --- a/src/translate_c/ast.zig +++ b/src/translate_c/ast.zig @@ -754,7 +754,7 @@ pub fn render(gpa: *Allocator, nodes: []const Node) !std.zig.ast.Tree { }); return std.zig.ast.Tree{ - .source = ctx.buf.toOwnedSlice(), + .source = try ctx.buf.toOwnedSliceSentinel(0), .tokens = ctx.tokens.toOwnedSlice(), .nodes = ctx.nodes.toOwnedSlice(), .extra_data = ctx.extra_data.toOwnedSlice(gpa), |
