From e47e60191df6369b7c44c99916cb77f23689c267 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Fri, 16 Sep 2022 20:43:57 +0200 Subject: [PATCH] inline chunk section index functions * Performance improvement --- .../de/bixilon/minosoft/data/world/chunk/ChunkSection.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/data/world/chunk/ChunkSection.kt b/src/main/java/de/bixilon/minosoft/data/world/chunk/ChunkSection.kt index 2a7821d23..908235564 100644 --- a/src/main/java/de/bixilon/minosoft/data/world/chunk/ChunkSection.kt +++ b/src/main/java/de/bixilon/minosoft/data/world/chunk/ChunkSection.kt @@ -104,13 +104,13 @@ class ChunkSection( companion object { - val Vec3i.index: Int + inline val Vec3i.index: Int get() = getIndex(x, y, z) - val Int.indexPosition: Vec3i + inline val Int.indexPosition: Vec3i get() = Vec3i(this and 0x0F, (this shr 8) and 0x0F, (this shr 4) and 0x0F) - fun getIndex(x: Int, y: Int, z: Int): Int { + inline fun getIndex(x: Int, y: Int, z: Int): Int { return y shl 8 or (z shl 4) or x } }