-
Notifications
You must be signed in to change notification settings - Fork 204
[Incremental] Obviate the need for a reverse mapping from swiftdeps to swift #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -542,22 +542,46 @@ extension OutputFileMap { | |
} | ||
|
||
// MARK: SourceFiles | ||
|
||
/// Handy information about the source files in the current invocation | ||
@_spi(Testing) public struct SourceFiles { | ||
/// The current files in same order as the invocation | ||
let currentInOrder: [TypedVirtualPath] | ||
private let previous: Set<VirtualPath> | ||
|
||
/// The set of current files (actually the handles) | ||
let currentSet: Set<VirtualPath.Handle> | ||
|
||
/// Handles of the input files in the previous invocation | ||
private let previousSet: Set<VirtualPath.Handle> | ||
|
||
/// The files that were in the previous but not in the current invocation | ||
let disappeared: [VirtualPath] | ||
|
||
init(inputFiles: [TypedVirtualPath], buildRecord: BuildRecord?) { | ||
self.currentInOrder = inputFiles.filter {$0.type == .swift} | ||
let currentSet = Set(currentInOrder.map {$0.file} ) | ||
self.previous = buildRecord.map { | ||
Set($0.inputInfos.keys) | ||
} ?? Set() | ||
|
||
self.disappeared = previous.filter {!currentSet.contains($0)} | ||
self.currentSet = currentInOrder.reduce(into: Set()) { | ||
currentSet, currentFile in | ||
currentSet.insert(currentFile.fileHandle) | ||
} | ||
guard let buildRecord = buildRecord else { | ||
self.previousSet = Set() | ||
self.disappeared = [] | ||
return | ||
} | ||
var previous = Set<VirtualPath.Handle>() | ||
var disappeared = [VirtualPath]() | ||
for prevPath in buildRecord.inputInfos.keys { | ||
let handle = prevPath.intern() | ||
previous.insert(handle) | ||
if !currentSet.contains(handle) { | ||
disappeared.append(prevPath) | ||
} | ||
} | ||
self.previousSet = previous | ||
self.disappeared = disappeared.sorted {$0.name < $1.name} | ||
} | ||
|
||
func isANewInput(_ file: VirtualPath) -> Bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this traffic in handles? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll look into it--good thought! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that changing |
||
!previous.contains(file) | ||
!previousSet.contains(file.intern()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the names cleanup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My pleasure!