mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Improve memory cost function of ASTBuildOperation
This commit is contained in:
@@ -246,6 +246,10 @@ struct FileContent {
|
||||
explicit operator InputFile() const {
|
||||
return InputFile(Filename, IsPrimary, Buffer.get());
|
||||
}
|
||||
|
||||
size_t getMemoryCost() const {
|
||||
return sizeof(*this) + Filename.size() + Buffer->getBufferSize();
|
||||
}
|
||||
};
|
||||
|
||||
/// An \c ASTBuildOperations builds an AST. Once the AST is built, it informs
|
||||
@@ -400,8 +404,12 @@ public:
|
||||
}
|
||||
|
||||
size_t getMemoryCost() {
|
||||
return sizeof(*this) + getVectorMemoryCost(FileContents) +
|
||||
Result.getMemoryCost();
|
||||
size_t Cost = sizeof(*this) + getVectorMemoryCost(FileContents) +
|
||||
Result.getMemoryCost();
|
||||
for (const FileContent &File : FileContents) {
|
||||
Cost += File.getMemoryCost();
|
||||
}
|
||||
return Cost;
|
||||
}
|
||||
|
||||
/// Schedule building this AST on the given \p Queue.
|
||||
|
||||
Reference in New Issue
Block a user