Skip to content

Commit 2ddacb1

Browse files
committed
Move targets(dependingOn:) call out of the changed files loop
We can call this function once we have gathered all changed targets instead of once for each changed file, which should be slightly more performant.
1 parent 909c0a9 commit 2ddacb1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,19 @@ package final actor SemanticIndexManager {
382382
let changedFiles = events.map(\.uri)
383383
await indexStoreUpToDateTracker.markOutOfDate(changedFiles)
384384

385-
// Preparation tracking should be per file. For now consider any non-known-language change as having to re-prepare
386-
// the target itself so that we re-prepare potential input files to plugins.
387-
// https://github.com/swiftlang/sourcekit-lsp/issues/1975
388385
var outOfDateTargets = Set<BuildTargetIdentifier>()
386+
var targetsOfChangedFiles = Set<BuildTargetIdentifier>()
389387
for file in changedFiles {
390388
let changedTargets = await buildSystemManager.targets(for: file)
389+
targetsOfChangedFiles.formUnion(changedTargets)
391390
if Language(inferredFromFileExtension: file) == nil {
391+
// Preparation tracking should be per file. For now consider any non-known-language change as having to
392+
// re-prepare the target itself so that we re-prepare potential input files to plugins.
393+
// https://github.com/swiftlang/sourcekit-lsp/issues/1975
392394
outOfDateTargets.formUnion(changedTargets)
393395
}
394-
395-
let dependentTargets = await buildSystemManager.targets(dependingOn: changedTargets)
396-
outOfDateTargets.formUnion(dependentTargets)
397396
}
397+
outOfDateTargets.formUnion(await buildSystemManager.targets(dependingOn: targetsOfChangedFiles))
398398
if !outOfDateTargets.isEmpty {
399399
logger.info(
400400
"""

0 commit comments

Comments
 (0)