[compiler] replace Enum values() with entries
To fix warnings. Also, use of `Enum.entries` may improve the performance ^KT-48872
This commit is contained in:
committed by
Space Team
parent
ec167d4d42
commit
072d191306
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -53,7 +53,7 @@ class KtConstantExpressionElementType(@NonNls debugName: String) :
|
||||
val kindOrdinal = dataStream.readInt()
|
||||
val value = dataStream.readName() ?: StringRef.fromString("")
|
||||
|
||||
val valueKind = ConstantValueKind.values()[kindOrdinal]
|
||||
val valueKind = ConstantValueKind.entries[kindOrdinal]
|
||||
|
||||
return KotlinConstantExpressionStubImpl(
|
||||
parentStub,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -14,8 +14,6 @@ import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.stubs.StubUtils
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
|
||||
enum class KotlinConstantValueKind {
|
||||
NULL, BOOLEAN, CHAR, BYTE, SHORT, INT, LONG, DOUBLE, FLOAT, ENUM, KCLASS, STRING, ARRAY, UBYTE, USHORT, UINT, ULONG, ANNO;
|
||||
@@ -24,7 +22,7 @@ enum class KotlinConstantValueKind {
|
||||
fun createConstantValue(dataStream: StubInputStream): ConstantValue<*>? {
|
||||
val kind = dataStream.readInt()
|
||||
if (kind == -1) return null
|
||||
return when (KotlinConstantValueKind.values()[kind]) {
|
||||
return when (KotlinConstantValueKind.entries[kind]) {
|
||||
KotlinConstantValueKind.NULL -> NullValue
|
||||
KotlinConstantValueKind.BOOLEAN -> BooleanValue(dataStream.readBoolean())
|
||||
KotlinConstantValueKind.CHAR -> CharValue(dataStream.readChar())
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ enum class KotlinContractEffectType {
|
||||
CALLS {
|
||||
override fun deserialize(dataStream: StubInputStream): KtCallsEffectDeclaration<KotlinTypeBean, Nothing?> {
|
||||
val declaration = PARAMETER_REFERENCE.deserialize(dataStream)
|
||||
val range = EventOccurrencesRange.values()[dataStream.readInt()]
|
||||
val range = EventOccurrencesRange.entries[dataStream.readInt()]
|
||||
return KtCallsEffectDeclaration(declaration as KtValueParameterReference, range)
|
||||
}
|
||||
},
|
||||
@@ -36,8 +36,8 @@ enum class KotlinContractEffectType {
|
||||
},
|
||||
CONDITIONAL {
|
||||
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
|
||||
val descriptionElement = values()[dataStream.readInt()].deserialize(dataStream)
|
||||
val condition = values()[dataStream.readInt()].deserialize(dataStream)
|
||||
val descriptionElement = entries[dataStream.readInt()].deserialize(dataStream)
|
||||
val condition = entries[dataStream.readInt()].deserialize(dataStream)
|
||||
return KtConditionalEffectDeclaration(
|
||||
descriptionElement as KtEffectDeclaration,
|
||||
condition as KtBooleanExpression
|
||||
@@ -63,14 +63,14 @@ enum class KotlinContractEffectType {
|
||||
},
|
||||
NOT {
|
||||
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
|
||||
return KtLogicalNot(values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression)
|
||||
return KtLogicalNot(entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression)
|
||||
}
|
||||
},
|
||||
BOOLEAN_LOGIC {
|
||||
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
|
||||
val kind = if (dataStream.readBoolean()) LogicOperationKind.AND else LogicOperationKind.OR
|
||||
val left = values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
|
||||
val right = values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
|
||||
val left = entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
|
||||
val right = entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
|
||||
return KtBinaryLogicExpression(left, right, kind)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.psi.stubs.impl
|
||||
@@ -70,7 +59,7 @@ class KotlinFunctionStubImpl(
|
||||
val effects = mutableListOf<KtContractDescriptionElement<KotlinTypeBean, Nothing?>>()
|
||||
val count: Int = dataStream.readInt()
|
||||
for (i in 0 until count) {
|
||||
val effectType: KotlinContractEffectType = KotlinContractEffectType.values()[dataStream.readInt()]
|
||||
val effectType: KotlinContractEffectType = KotlinContractEffectType.entries[dataStream.readInt()]
|
||||
effects.add(effectType.deserialize(dataStream))
|
||||
}
|
||||
return effects
|
||||
|
||||
Reference in New Issue
Block a user