Skip to content

Commit

Permalink
perf(spdx-utils): Make the cheap check go first
Browse files Browse the repository at this point in the history
This avoids potentially expensive `validChoices()` calls on literal
expression matches.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jan 25, 2024
1 parent 5364048 commit 47da430
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/spdx/src/main/kotlin/SpdxExpression.kt
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class SpdxCompoundExpression(
val expressionString = toString()
val subExpressionString = subExpression.toString()

return validChoices().containsAll(subExpression.validChoices()) || subExpressionString in expressionString
return subExpressionString in expressionString || validChoices().containsAll(subExpression.validChoices())
}

override fun equals(other: Any?): Boolean {
Expand Down

0 comments on commit 47da430

Please sign in to comment.