Skip to content

Commit

Permalink
Revert "Correct conditions in equality check to prepare for YAML"
Browse files Browse the repository at this point in the history
Don't see any possibility to use Kaml in the nearest future.
Better to use operation with less cost first

This reverts commit f3339d8.
  • Loading branch information
OptimumCode committed Aug 31, 2024
1 parent 37f84a3 commit 705cdb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ internal fun areEqualPrimitives(
if (first.isString != second.isString) {
return false
}
return when {
first.isNumber && second.isNumber -> compareAsNumbers(first, second)
// probably content should be compared ignoring the case - YAML allows different values for boolean
first.isBoolean && second.isBoolean -> first.content == second.content
first.isString -> first.content == second.content
else -> false
return if (first.isString) {
first.content == second.content
} else {
when {
first.isNull || second.isNull -> false
// probably content should be compared ignoring the case - YAML allows different values for boolean
first.isBoolean || second.isBoolean -> first.content == second.content
else -> compareAsNumbers(first, second)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ internal data class NumberParts(
val precision: Int,
)

internal fun parseNumberParts(element: PrimitiveElement): NumberParts? =
if (element.isNumber) {
numberParts(element)
} else {
internal fun parseNumberParts(element: PrimitiveElement): NumberParts? {
return if (element.isString || element.isNull || element.isBoolean) {
null
} else {
numberParts(element)
}
}

private const val E_SMALL_CHAR: Char = 'e'
private const val E_BIG_CHAR: Char = 'E'
Expand Down

0 comments on commit 705cdb8

Please sign in to comment.