# compiler: remove Cau · gitcafe/zig

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

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

Visibility: public

Requested revision: 40aafcd6a85d3c517f445f17149c17523c832420

Requested commit: 40aafcd6a85d3c517f445f17149c17523c832420

Commit: 40aafcd6a85d3c517f445f17149c17523c832420

Tree: b8e1a5361c6a20ce9e3ba568b61b199aff1c8f13

Author: mlugg

Committer: mlugg

## Message

```
compiler: remove Cau

The `Cau` abstraction originated from noting that one of the two primary
roles of the legacy `Decl` type was to be the subject of comptime
semantic analysis. However, the data stored in `Cau` has always had some
level of redundancy. While preparing for #131, I went to remove that
redundany, and realised that `Cau` now had exactly one field: `owner`.

This led me to conclude that `Cau` is, in fact, an unnecessary level of
abstraction over what are in reality *fundamentally different* kinds of
analysis unit (`AnalUnit`). Types, `Nav` vals, and `comptime`
declarations are all analyzed in different ways, and trying to treat
them as the same thing is counterproductive!

So, these 3 cases are now different alternatives in `AnalUnit`. To avoid
stealing bits from `InternPool`-based IDs, which are already a little
starved for bits due to the sharding datastructures, `AnalUnit` is
expanded to 64 bits (30 of which are currently unused). This doesn't
impact memory usage too much by default, because we don't store
`AnalUnit`s all too often; however, we do store them a lot under
`-fincremental`, so a non-trivial bump to peak RSS can be observed
there. This will be improved in the future when I made
`InternPool.DepEntry` less memory-inefficient.

`Zcu.PerThread.ensureCauAnalyzed` is split into 3 functions, for each of
the 3 new types of `AnalUnit`. The new logic is much easier to
understand, because it avoids conflating the logic of these
fundamentally different cases.

```

## Parents

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

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