Skip to content

Commit

Permalink
chore(evaluator): Prefer asList() to convert vararg
Browse files Browse the repository at this point in the history
This avoids unnecessary copies.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Dec 12, 2024
1 parent 7abe559 commit 94ba630
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions evaluator/src/main/kotlin/ProjectSourceRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ open class ProjectSourceRule(
*/
fun projectSourceFindDirectories(vararg patterns: String): List<File> =
projectSourcesDir.walkBottomUp().filterTo(mutableListOf()) {
it.isDirectory && FileMatcher.match(patterns.toList(), it.relativeTo(projectSourcesDir).path)
it.isDirectory && FileMatcher.match(patterns.asList(), it.relativeTo(projectSourcesDir).path)
}

/**
* Return all files from the project's source tree which match any of the provided [glob expressions][patterns].
*/
fun projectSourceFindFiles(vararg patterns: String): List<File> =
projectSourcesDir.walkBottomUp().filterTo(mutableListOf()) {
it.isFile && FileMatcher.match(patterns.toList(), it.relativeTo(projectSourcesDir).path)
it.isFile && FileMatcher.match(patterns.asList(), it.relativeTo(projectSourcesDir).path)
}

/**
* Return the detected licenses for any file matching the given [glob expressions][patterns].
*/
fun projectSourceGetDetectedLicensesByFilePath(vararg patterns: String): Map<String, Set<String>> =
detectedLicensesForFilePath.filter { (filePath, _) ->
FileMatcher.match(patterns.toList(), filePath)
FileMatcher.match(patterns.asList(), filePath)
}

/**
Expand Down

0 comments on commit 94ba630

Please sign in to comment.