[regex] Minor naming refactoring
This commit is contained in:
committed by
Ilya Matveev
parent
6cacbfbc36
commit
3610588666
@@ -88,49 +88,47 @@ internal abstract class AbstractCharClass : SpecialToken() {
|
|||||||
|
|
||||||
|
|
||||||
private val surrogates_ = AtomicReference<AbstractCharClass?>(null)
|
private val surrogates_ = AtomicReference<AbstractCharClass?>(null)
|
||||||
val surrogates: AbstractCharClass
|
fun classWithSurrogates(): AbstractCharClass {
|
||||||
get() {
|
surrogates_.value?.let {
|
||||||
surrogates_.value?.let {
|
return it
|
||||||
return it
|
}
|
||||||
}
|
val surrogates = lowHighSurrogates
|
||||||
val surrogates = lowHighSurrogates
|
val result = object : AbstractCharClass() {
|
||||||
val result = object : AbstractCharClass() {
|
override fun contains(ch: Int): Boolean {
|
||||||
override fun contains(ch: Int): Boolean {
|
val index = ch - Char.MIN_SURROGATE.toInt()
|
||||||
val index = ch - Char.MIN_SURROGATE.toInt()
|
|
||||||
|
|
||||||
return if (index >= 0 && index < AbstractCharClass.SURROGATE_CARDINALITY) {
|
return if (index >= 0 && index < AbstractCharClass.SURROGATE_CARDINALITY) {
|
||||||
this.altSurrogates xor surrogates[index]
|
this.altSurrogates xor surrogates[index]
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.setNegative(this.altSurrogates)
|
|
||||||
surrogates_.compareAndSet(null, result.freeze())
|
|
||||||
return surrogates_.value!!
|
|
||||||
}
|
}
|
||||||
|
result.setNegative(this.altSurrogates)
|
||||||
|
surrogates_.compareAndSet(null, result.freeze())
|
||||||
|
return surrogates_.value!!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// We cannot cache this class as we've done with surrogates above because
|
// We cannot cache this class as we've done with surrogates above because
|
||||||
// here is a circular reference between it and AbstractCharClass.
|
// here is a circular reference between it and AbstractCharClass.
|
||||||
val withoutSurrogates: AbstractCharClass
|
fun classWithoutSurrogates(): AbstractCharClass {
|
||||||
get() {
|
val result = object : AbstractCharClass() {
|
||||||
val result = object : AbstractCharClass() {
|
override fun contains(ch: Int): Boolean {
|
||||||
override fun contains(ch: Int): Boolean {
|
val index = ch - Char.MIN_SURROGATE.toInt()
|
||||||
val index = ch - Char.MIN_SURROGATE.toInt()
|
|
||||||
|
|
||||||
val containslHS = if (index >= 0 && index < AbstractCharClass.SURROGATE_CARDINALITY)
|
val containslHS = if (index >= 0 && index < AbstractCharClass.SURROGATE_CARDINALITY)
|
||||||
this.altSurrogates xor this@AbstractCharClass.lowHighSurrogates.get(index)
|
this.altSurrogates xor this@AbstractCharClass.lowHighSurrogates.get(index)
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
|
||||||
return this@AbstractCharClass.contains(ch) && !containslHS
|
return this@AbstractCharClass.contains(ch) && !containslHS
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result.setNegative(isNegative())
|
|
||||||
result.mayContainSupplCodepoints = mayContainSupplCodepoints
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
result.setNegative(isNegative())
|
||||||
|
result.mayContainSupplCodepoints = mayContainSupplCodepoints
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets this CharClass to negative form, i.e. if they will add some characters and after that set this
|
* Sets this CharClass to negative form, i.e. if they will add some characters and after that set this
|
||||||
|
|||||||
@@ -774,13 +774,13 @@ internal class Pattern(val pattern: String, flags: Int = 0) {
|
|||||||
|
|
||||||
private fun processRangeSet(charClass: AbstractCharClass): AbstractSet {
|
private fun processRangeSet(charClass: AbstractCharClass): AbstractSet {
|
||||||
if (charClass.hasLowHighSurrogates()) {
|
if (charClass.hasLowHighSurrogates()) {
|
||||||
val lowHighSurrRangeSet = SurrogateRangeSet(charClass.surrogates)
|
val lowHighSurrRangeSet = SurrogateRangeSet(charClass.classWithSurrogates())
|
||||||
|
|
||||||
if (charClass.mayContainSupplCodepoints) {
|
if (charClass.mayContainSupplCodepoints) {
|
||||||
return CompositeRangeSet(SupplementaryRangeSet(charClass.withoutSurrogates, hasFlag(CASE_INSENSITIVE)), lowHighSurrRangeSet)
|
return CompositeRangeSet(SupplementaryRangeSet(charClass.classWithoutSurrogates(), hasFlag(CASE_INSENSITIVE)), lowHighSurrRangeSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompositeRangeSet(RangeSet(charClass.withoutSurrogates, hasFlag(CASE_INSENSITIVE)), lowHighSurrRangeSet)
|
return CompositeRangeSet(RangeSet(charClass.classWithoutSurrogates(), hasFlag(CASE_INSENSITIVE)), lowHighSurrRangeSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (charClass.mayContainSupplCodepoints) {
|
if (charClass.mayContainSupplCodepoints) {
|
||||||
|
|||||||
Reference in New Issue
Block a user