diff --git a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/config/EcoConfig.kt b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/config/EcoConfig.kt index 459e8000..0ba8e541 100644 --- a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/config/EcoConfig.kt +++ b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/config/EcoConfig.kt @@ -7,7 +7,6 @@ import com.willfp.eco.core.placeholder.context.PlaceholderContext import com.willfp.eco.internal.fast.listView import com.willfp.eco.util.StringUtils import org.bukkit.configuration.file.YamlConfiguration -import java.util.Objects import java.util.concurrent.ConcurrentHashMap @Suppress("UNCHECKED_CAST") @@ -259,13 +258,12 @@ open class EcoConfig( var injectionHash = 0 - for (injection in injections.values) { - injectionHash = injectionHash * 31 + injection.hashCode() + injections.forEachValue(5) { + injectionHash = injectionHash xor (it.hashCode() shl 5) } - return Objects.hash( - values, - configType - ) + injectionHash + // hashCode() has to compute extremely quickly, so we're using bitwise, because why not? + // Fucking filthy to use identityHashCode here, but it should be extremely fast + return ((System.identityHashCode(this) shl 5) - (System.identityHashCode(this) xor configType.hashCode()) + injectionHash) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt index e44384a7..73b116cd 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt @@ -4,7 +4,6 @@ import com.github.benmanes.caffeine.cache.Cache import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.placeholder.context.PlaceholderContext -import java.util.Objects import java.util.concurrent.TimeUnit class DelegatedExpressionHandler( @@ -16,11 +15,10 @@ class DelegatedExpressionHandler( .build() override fun evaluate(expression: String, context: PlaceholderContext): Double { - val hash = Objects.hash( - expression, - context.player?.uniqueId, - context.injectableContext - ) + // Peak performance (totally not having fun with bitwise operators) + val hash = (((expression.hashCode() shl 5) - expression.hashCode()) xor + (context.player?.uniqueId?.hashCode() ?: 0) + ) xor context.injectableContext.hashCode() return evaluationCache.get(hash) { handler.evaluate(expression, context)