From 801f1a817e2919d9d38510600c7f3212f1b50587 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Thu, 25 Jan 2024 12:45:07 +0100 Subject: [PATCH] perf(spdx-utils): Make the cheap check go first This avoids potentially expensive `validChoices()` calls on literal expression matches. Signed-off-by: Sebastian Schuberth --- utils/spdx/src/main/kotlin/SpdxExpression.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/spdx/src/main/kotlin/SpdxExpression.kt b/utils/spdx/src/main/kotlin/SpdxExpression.kt index 0752da4652681..8ce617adcb6a5 100644 --- a/utils/spdx/src/main/kotlin/SpdxExpression.kt +++ b/utils/spdx/src/main/kotlin/SpdxExpression.kt @@ -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 {