# InternPool: avoid indexToKey recursion for opt_payload · gitcafe/zig

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

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

Visibility: public

Requested revision: f7177fb8215714f9f22e3f9da0d3c7d3ad58d390

Requested commit: f7177fb8215714f9f22e3f9da0d3c7d3ad58d390

Commit: f7177fb8215714f9f22e3f9da0d3c7d3ad58d390

Tree: 21b113788cf614164b11a3f3968543e352080be0

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
InternPool: avoid indexToKey recursion for opt_payload

This is a hot function, and recursion makes it more difficult to
profile, as well as likely making it more difficult to optimize.

Previously, indexToKey for opt_payload would call getAssumeExists() on
the optional type. This made it possible to omit the optional type in
the encoding of opt_payload. However, getAssumeExists() *must* call
indexToKey because of hashing/equality.

So, this commit adds the optional type to the opt_payload encoding,
which increases its "extra" size from 0 to 8 bytes. As a result,
the opt_payload encoding went from not showing up on the top 25 largest
tags to...still not showing up in the top 25 largest tags.

This also helps make InternPool.typeOf() no longer need to call
indexToKey which is another hot function and another source of
recursion.

```

## Parents

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

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