# use singly linked lists for std.zig.parse · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/93384f7428c5186a1b44c6f5f8891ce40bc46e72)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 93384f7428c5186a1b44c6f5f8891ce40bc46e72

Requested commit: 93384f7428c5186a1b44c6f5f8891ce40bc46e72

Commit: 93384f7428c5186a1b44c6f5f8891ce40bc46e72

Tree: 2baa7d2fcfc0ba0b088d45ccdb01543d480f42ff

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
use singly linked lists for std.zig.parse

std.ast uses a singly linked list for lists of things. This is a
breaking change to the self-hosted parser API.

std.ast.Tree has been separated into a private "Parser" type which
represents in-progress parsing, and std.ast.Tree which has only
"output" data. This means cleaner, but breaking, API for parse results.
Specifically, `tokens` and `errors` are no longer SegmentedList but a
slice.

The way to iterate over AST nodes has necessarily changed since lists of
nodes are now singly linked lists rather than SegmentedList.

From these changes, I observe the following on the
self-hosted-parser benchmark from ziglang/gotta-go-fast:

throughput: 45.6 MiB/s => 55.6 MiB/s
maxrss: 359 KB => 342 KB

This commit breaks the build; more updates are necessary to fix API
usage of the self-hosted parser.

```

## Parents

- [ed137d25ef0fb94f2ea0db4f993a0adfcaf63b58](https://git.cafe/gitcafe/zig/commit/ed137d25ef0fb94f2ea0db4f993a0adfcaf63b58?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/93384f7428c5186a1b44c6f5f8891ce40bc46e72?format=markdown)
