[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:
Dmitrii Gridin
2024-02-15 00:02:32 +01:00
committed by Space Team
parent ec167d4d42
commit 072d191306
60 changed files with 174 additions and 267 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -70,7 +70,7 @@ class ApiVersion private constructor(
val KOTLIN_2_1 = createByLanguageVersion(LanguageVersion.KOTLIN_2_1)
@JvmField
val LATEST: ApiVersion = createByLanguageVersion(LanguageVersion.values().last())
val LATEST: ApiVersion = createByLanguageVersion(LanguageVersion.entries.last())
@JvmField
val LATEST_STABLE: ApiVersion = createByLanguageVersion(LanguageVersion.LATEST_STABLE)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 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.
*/
@@ -11,8 +11,8 @@ enum class ExplicitApiMode(val state: String) {
WARNING("warning");
companion object {
fun fromString(string: String): ExplicitApiMode? = values().find { it.state == string }
fun fromString(string: String): ExplicitApiMode? = entries.find { it.state == string }
fun availableValues() = values().joinToString(prefix = "{", postfix = "}") { it.state }
fun availableValues() = entries.joinToString(prefix = "{", postfix = "}") { it.state }
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -469,7 +469,7 @@ enum class LanguageFeature(
companion object {
@JvmStatic
fun fromString(str: String) = values().find { it.name == str }
fun fromString(str: String) = entries.find { it.name == str }
}
}
@@ -507,7 +507,7 @@ enum class LanguageVersion(val major: Int, val minor: Int) : DescriptionAware, L
companion object {
@JvmStatic
fun fromVersionString(str: String?) = values().find { it.versionString == str }
fun fromVersionString(str: String?) = entries.find { it.versionString == str }
@JvmStatic
fun fromFullVersionString(str: String) =