Skip to content

Commit

Permalink
refactor(swiftpm): Avoid an unnecessary copy operation
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Feb 7, 2024
1 parent 4e8ca76 commit 487bf92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class SwiftPm(

return listOf(
ProjectAnalyzerResult(
project = projectFromDefinitionFile(packageResolvedFile),
project = projectFromDefinitionFile(packageResolvedFile, emptySet()),
packages = pins.mapTo(mutableSetOf()) { it.toPackage() },
issues = issues
)
Expand All @@ -114,7 +114,6 @@ class SwiftPm(
* Also, this method provides parent-child associations for parsed dependencies.
*/
private fun resolveDefinitionFileDependencies(packageSwiftFile: File): List<ProjectAnalyzerResult> {
val project = projectFromDefinitionFile(packageSwiftFile)
val swiftPackage = getSwiftPackage(packageSwiftFile)

val issues = mutableListOf<Issue>()
Expand All @@ -135,7 +134,7 @@ class SwiftPm(

return listOf(
ProjectAnalyzerResult(
project = project.copy(scopeDependencies = scopeDependencies),
project = projectFromDefinitionFile(packageSwiftFile, scopeDependencies),
packages = packages,
issues = issues
)
Expand All @@ -155,7 +154,7 @@ class SwiftPm(
return parseSwiftPackage(result)
}

private fun projectFromDefinitionFile(definitionFile: File): Project {
private fun projectFromDefinitionFile(definitionFile: File, scopeDependencies: Set<Scope>): Project {
val vcsInfo = VersionControlSystem.forDirectory(definitionFile.parentFile)?.getInfo().orEmpty()

val projectIdentifier = Identifier(
Expand All @@ -170,6 +169,7 @@ class SwiftPm(
id = projectIdentifier,
declaredLicenses = emptySet(),
homepageUrl = "",
scopeDependencies = scopeDependencies,
vcsProcessed = processProjectVcs(definitionFile.parentFile),
definitionFilePath = VersionControlSystem.getPathInfo(definitionFile).path
)
Expand Down

0 comments on commit 487bf92

Please sign in to comment.