Avoid calling to_kind() in is_air() (#142)

This PR changes is_air() to not call to_kind() to increase performance.

Example flamegraphs of real usecase of parsing java chunks to
UnloadedChunk:

Before this change:

![flamegraph](https://user-images.githubusercontent.com/13693773/198851700-f455d055-a18d-495c-9989-110e3f569ad9.svg)



After this change:

![flamegraph](https://user-images.githubusercontent.com/13693773/198851673-01f2a6d8-1cb0-4ae7-b57b-6e47a38d9cee.svg)
This commit is contained in:
Terminator 2022-10-29 22:56:48 +02:00 committed by GitHub
parent 56ebcaf50d
commit e80bbc22b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -511,8 +511,8 @@ pub fn build() -> anyhow::Result<TokenStream> {
/// If this block is `air`, `cave_air` or `void_air`.
pub const fn is_air(self) -> bool {
matches!(
self.to_kind(),
BlockKind::Air | BlockKind::CaveAir | BlockKind::VoidAir
self,
BlockState::AIR | BlockState::CAVE_AIR | BlockState::VOID_AIR
)
}