[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
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ enum class JVMAssertionsMode(val description: String) {
|
||||
val DEFAULT = LEGACY
|
||||
|
||||
@JvmStatic
|
||||
fun fromStringOrNull(string: String?) = values().find { it.description == string }
|
||||
fun fromStringOrNull(string: String?) = entries.find { it.description == string }
|
||||
|
||||
@JvmStatic
|
||||
fun fromString(string: String?) = fromStringOrNull(string) ?: DEFAULT
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,6 @@ enum class JvmAbiStability(val description: String) {
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromStringOrNull(string: String?): JvmAbiStability? =
|
||||
values().find { it.description == string }
|
||||
fun fromStringOrNull(string: String?): JvmAbiStability? = entries.find { it.description == string }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ enum class JvmClosureGenerationScheme(val description: String) {
|
||||
@JvmStatic
|
||||
fun fromString(string: String?): JvmClosureGenerationScheme? {
|
||||
val lowerStr = string?.toLowerCaseAsciiOnly() ?: return null
|
||||
return values().find { it.description == lowerStr }
|
||||
return entries.find { it.description == lowerStr }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ enum class JvmSerializeIrMode(val description: String) {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromStringOrNull(string: String) = values().find { it.description == string }
|
||||
fun fromStringOrNull(string: String) = entries.find { it.description == string }
|
||||
|
||||
@JvmStatic
|
||||
fun fromString(string: String) = fromStringOrNull(string) ?: NONE
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,6 @@ enum class JvmStringConcat(val description: String) {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromString(string: String) = values().find { it.description == string }
|
||||
fun fromString(string: String) = entries.find { it.description == string }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
* 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.platform.jvm
|
||||
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.platform.jvm
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.platform.SimplePlatform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.toTargetPlatform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
||||
import org.jetbrains.kotlin.platform.toTargetPlatform
|
||||
|
||||
abstract class JvmPlatform : SimplePlatform("JVM") {
|
||||
override val oldFashionedDescription: String
|
||||
@@ -20,7 +20,7 @@ abstract class JvmPlatform : SimplePlatform("JVM") {
|
||||
object JvmPlatforms {
|
||||
private val UNSPECIFIED_SIMPLE_JVM_PLATFORM = JdkPlatform(JvmTarget.DEFAULT)
|
||||
private val jvmTargetToJdkPlatform: Map<JvmTarget, TargetPlatform> =
|
||||
JvmTarget.values().map { it to JdkPlatform(it).toTargetPlatform() }.toMap()
|
||||
JvmTarget.entries.map { it to JdkPlatform(it).toTargetPlatform() }.toMap()
|
||||
|
||||
// This platform is needed mostly for compatibility and migration of code base,
|
||||
// as previously some clients used TargetPlatform just as platform-marker
|
||||
|
||||
Reference in New Issue
Block a user