Skip to content

Commit aa10427

Browse files
authored
Merge pull request #1126 from owenv/swiftdeps-deserialize-perf
Reapply "Explicitly copy defsIDependUpon into an appropriately sized array when initializing SourceFileDependencyGraph.Node"
2 parents 713b517 + 4f575fc commit aa10427

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)