July 30, 2026, 8:40pm 1
Since std.builtin.SourceLocation uses .line and .column for its position, reading a zig file at a SourceLocation requires counting new lines to find that position.
Having .offset as well could make it possible to read to a source location with readPositional or use a memory map and slice from the .offset without scanning the file.
I image it’s because source locations are very numerous (an additional field takes up memory) and the need to show source lines is rare and not in a hot path.
I got your point but I think (no statistics to back it up) when dealing with text/source files one usually loads it all in memory so a simple structure like text_lines: [][]const u8 is OK to handle and .line and .column suits the need just fine.
Now, if you are coding an editor, that’s a completely different thing …
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.