From 092728b1c328a6e515de5c68ade5e99bc460c4e5 Mon Sep 17 00:00:00 2001 From: Iaroslav Date: Fri, 26 Jun 2020 16:01:50 +0700 Subject: [PATCH] Replace Stack with ArrayDeque --- .../scientifik/kmath/asm/internal/AsmBuilder.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmBuilder.kt b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmBuilder.kt index 89c9dca9d..c9f797787 100644 --- a/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmBuilder.kt +++ b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmBuilder.kt @@ -91,12 +91,12 @@ internal class AsmBuilder internal constructor( /** * Stack of useful objects types on stack to verify types. */ - private val typeStack: Stack = Stack() + private val typeStack: ArrayDeque = ArrayDeque() /** * Stack of useful objects types on stack expected by algebra calls. */ - internal val expectationStack: Stack = Stack().apply { push(tType) } + internal val expectationStack: ArrayDeque = ArrayDeque().apply { push(tType) } /** * The cache for instance built by this builder. @@ -270,7 +270,7 @@ internal class AsmBuilder internal constructor( */ internal fun loadTConstant(value: T) { if (classOfT in INLINABLE_NUMBERS) { - val expectedType = expectationStack.pop()!! + val expectedType = expectationStack.pop() val mustBeBoxed = expectedType.sort == Type.OBJECT loadNumberConstant(value as Number, mustBeBoxed) if (mustBeBoxed) typeStack.push(tType) else typeStack.push(primitiveMask) @@ -371,7 +371,7 @@ internal class AsmBuilder internal constructor( checkcast(tType) - val expectedType = expectationStack.pop()!! + val expectedType = expectationStack.pop() if (expectedType.sort == Type.OBJECT) typeStack.push(tType) @@ -405,7 +405,7 @@ internal class AsmBuilder internal constructor( ) { run loop@{ repeat(expectedArity) { - if (typeStack.empty()) return@loop + if (typeStack.isEmpty()) return@loop typeStack.pop() } } @@ -420,7 +420,7 @@ internal class AsmBuilder internal constructor( invokeMethodVisitor.checkcast(tType) val isLastExpr = expectationStack.size == 1 - val expectedType = expectationStack.pop()!! + val expectedType = expectationStack.pop() if (expectedType.sort == Type.OBJECT || isLastExpr) typeStack.push(tType)