mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Delay adding ModuleFiles until they're loaded
Rather than adding a ModuleFile to a parent module and then removing it afterwards if it fails to load, let's wait until we've loaded the file before deciding to add it to the parent module. This then allows us to get rid of `ModuleDecl::removeFile`. In addition, push down the calls to `addFile` into the callers of `loadAST` in preparation for `addFile` being replaced with a one-time-only call to a `setFiles` method.
This commit is contained in:
@@ -507,19 +507,6 @@ void ModuleDecl::addFile(FileUnit &newFile) {
|
||||
clearLookupCache();
|
||||
}
|
||||
|
||||
void ModuleDecl::removeFile(FileUnit &existingFile) {
|
||||
// Do a reverse search; usually the file to be deleted will be at the end.
|
||||
std::reverse_iterator<decltype(Files)::iterator> I(Files.end()),
|
||||
E(Files.begin());
|
||||
I = std::find(I, E, &existingFile);
|
||||
assert(I != E);
|
||||
|
||||
// Adjust for the std::reverse_iterator offset.
|
||||
++I;
|
||||
Files.erase(I.base());
|
||||
clearLookupCache();
|
||||
}
|
||||
|
||||
#define FORWARD(name, args) \
|
||||
for (const FileUnit *file : getFiles()) \
|
||||
file->name args;
|
||||
|
||||
Reference in New Issue
Block a user