# \[priority_deque\] simplify & optimize isMinLayer · gitcafe/zig

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

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

Visibility: public

Requested revision: ff5850183eee854fdfe0d3f7b7242b9ff56c2116

Requested commit: ff5850183eee854fdfe0d3f7b7242b9ff56c2116

Commit: ff5850183eee854fdfe0d3f7b7242b9ff56c2116

Tree: 715ed346487b0f221f92e26280ea5e5b52a9254a

Author: Niles Salter

Committer: Andrew Kelley

## Message

```
[priority_deque] simplify & optimize isMinLayer

LLVM has trouble compiling the old implementation, (presumably) because `leading_zeros` is thought to be a `u7` rather than a `u6`, which means `63 - clz` is not equivalent to `63 ^ clz`, which means it can't deduce that the final condition can simply be flipped. (I am assuming `usize` is a `u64` here for ease of understanding, but it's the same for any power of 2)

https://zig.godbolt.org/z/Pbj4P7ob3

The new version is slightly better too because `isMinLayer(maxInt(usize))` is now well-defined behavior.
```

## Parents

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

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