Commit 3f7bab7373

Vexu <git@vexu.eu>
2019-12-21 13:40:47
fix translate-c taking ages
1 parent fceda07
Changed files (2)
lib
std
src-self-hosted
lib/std/zig/ast.zig
@@ -13,6 +13,7 @@ pub const Tree = struct {
     root_node: *Node.Root,
     arena_allocator: std.heap.ArenaAllocator,
     errors: ErrorList,
+    generated: bool = false,
 
     pub const TokenList = SegmentedList(Token, 64);
     pub const ErrorList = SegmentedList(Error, 0);
@@ -58,6 +59,8 @@ pub const Tree = struct {
             .line_start = start_index,
             .line_end = self.source.len,
         };
+        if (self.generated)
+            return loc;
         const token_start = token.start;
         for (self.source[start_index..]) |c, i| {
             if (i + start_index == token_start) {
src-self-hosted/translate_c.zig
@@ -249,6 +249,7 @@ pub fn translate(
             .arena_allocator = tree_arena,
             .tokens = undefined, // can't reference the allocator yet
             .errors = undefined, // can't reference the allocator yet
+            .generated = true,
         };
         break :blk tree;
     };