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

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

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

Visibility: public

Requested revision: 55cda9a592dd5aa030d1134351394e1014fefed1

Requested commit: 55cda9a592dd5aa030d1134351394e1014fefed1

Commit: 55cda9a592dd5aa030d1134351394e1014fefed1

Tree: 9d6f6d7d580260467de89ff9562e5ffda8f6d46e

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
InternPool: avoid indexToKey recursion for ptr_slice

Recursion makes this hot function more difficult to profile and
optimize.

The ptr_slice encoding now additionally includes the slice type. This
makes typeOf() implementable without indexToKey() as well as no longer
using recursion in the ptr_slice prong of indexToKey itself.

Unfortunately some logic had to be duplicated. However, I think that a
future enhancement could eliminate the duplication as well as remove
some other unwanted code, improving performance, by representing a slice
value in `Key.Ptr` without `addr` populated directly, but with an
`Index` pointing to the underlying manyptr value.

```

## Parents

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

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