Skip to content

Commit 8f7b30b

Browse files
authored
Merge pull request #1124 from owenv/5_7-swiftdeps-perf
[5.7] Explicitly copy defsIDependUpon into an appropriately sized array when initializing SourceFileDependencyGraph.Node
2 parents 6196421 + ec8128d commit 8f7b30b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/SwiftDriver/IncrementalCompilation/SourceFileDependencyGraph.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,14 @@ extension SourceFileDependencyGraph {
227227
private mutating func finalizeNode() throws {
228228
guard let key = key else {return}
229229

230+
let defsIDependUpon: [Int] = Array(unsafeUninitializedCapacity: defsNodeDependUpon.count) { destinationBuffer, initializedCount in
231+
_ = destinationBuffer.initialize(from: defsNodeDependUpon)
232+
initializedCount = defsNodeDependUpon.count
233+
}
230234
let node = try Node(key: key,
231235
fingerprint: fingerprint?.intern(in: internedStringTable),
232236
sequenceNumber: nodeSequenceNumber,
233-
defsIDependUpon: defsNodeDependUpon,
237+
defsIDependUpon: defsIDependUpon,
234238
definitionVsUse: definitionVsUse)
235239
self.key = nil
236240
self.defsNodeDependUpon.removeAll(keepingCapacity: true)

0 commit comments

Comments
 (0)