mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 22:41:30 +11:00
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:
parent
56ebcaf50d
commit
e80bbc22b3
|
@ -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
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue