From 2673736cb6eab04aa8f0260f77e75d3e26717d1c Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 17 Nov 2017 13:14:42 +0100 Subject: [PATCH] simplify code (kotlin) --- .../configuration-store-impl/src/StateMap.kt | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/platform/configuration-store-impl/src/StateMap.kt b/platform/configuration-store-impl/src/StateMap.kt index 170c9045fb03..43d06f92c48f 100644 --- a/platform/configuration-store-impl/src/StateMap.kt +++ b/platform/configuration-store-impl/src/StateMap.kt @@ -130,16 +130,7 @@ class StateMap private constructor(private val names: Array, private val fun hasState(key: String) = get(key) is Element fun hasStates(): Boolean { - if (isEmpty()) { - return false - } - - for (i in names.indices) { - if (states.get(i) is Element) { - return true - } - } - return false + return !isEmpty() && names.indices.any { states.get(it) is Element } } fun compare(key: String, newStates: StateMap, diffs: MutableSet) { @@ -241,16 +232,5 @@ private fun arrayEquals(a: ByteArray, a2: ByteArray, size: Int = a.size): Boolea if (a === a2) { return true } - - if (a2.size != size) { - return false - } - - for (i in 0 until size) { - if (a[i] != a2[i]) { - return false - } - } - - return true + return a2.size == size && (0 until size).none { a[it] != a2[it] } } \ No newline at end of file