KT-53327 replace Enum.values() with Enum.entries in CharCategory

Also, replace it in stdlib tests where appropriate and disable already unsupported legacy JS tests


^KT-53327 fixed

Co-authored-by: Artem Kobzar <Artem.Kobzar@jetbrains.com>

Merge-request: KT-MR-10632
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
This commit is contained in:
Vsevolod Tolstopyatov
2023-06-21 14:40:16 +00:00
committed by Space Team
parent c867a4b52f
commit 175cf5e833
13 changed files with 30 additions and 30 deletions
@@ -166,9 +166,9 @@ public actual enum class CharCategory(internal val value: Int, public actual val
public companion object {
internal fun valueOf(category: Int): CharCategory =
when (category) {
in 0..16 -> values()[category]
in 18..30 -> values()[category - 1]
in 0..16 -> entries[category]
in 18..30 -> entries[category - 1]
else -> throw IllegalArgumentException("Category #$category is not defined.")
}
}
}
}
@@ -10,7 +10,7 @@ import kotlin.text.regex.*
private fun Iterable<RegexOption>.toInt(): Int = this.fold(0, { value, option -> value or option.value })
private fun fromInt(value: Int): Set<RegexOption> =
RegexOption.values().filterTo(mutableSetOf<RegexOption>()) { value and it.mask == it.value }
RegexOption.entries.filterTo(mutableSetOf<RegexOption>()) { value and it.mask == it.value }
/**
* Provides enumeration values to use to set regular expression options.
@@ -635,10 +635,10 @@ internal abstract class AbstractCharClass : SpecialToken() {
PF("Pf", { CachedCategory(CharCategory.FINAL_QUOTE_PUNCTUATION.value, false) })
}
private val classCache = Array<AtomicReference<CachedCharClass?>>(CharClasses.values().size, {
private val classCache = Array<AtomicReference<CachedCharClass?>>(CharClasses.entries.size, {
AtomicReference<CachedCharClass?>(null)
})
private val classCacheMap = CharClasses.values().associate { it -> it.regexName to it }
private val classCacheMap = CharClasses.entries.associate { it -> it.regexName to it }
fun intersects(ch1: Int, ch2: Int): Boolean = ch1 == ch2
fun intersects(cc: AbstractCharClass, ch: Int): Boolean = cc.contains(ch)