[clang] [clang][modules] Avoid allocations when reading blob paths (PR #113984)
Ben Langmuir via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 30 09:05:04 PDT 2024
================
@@ -1342,19 +1343,47 @@ class ASTReader
bool Complain = true);
/// Buffer we use as temporary storage backing resolved paths.
- SmallString<256> PathBuf;
+ std::optional<SmallString<256>> PathBuf{{}};
+
+ /// A RAII wrapper around \c StringRef that temporarily takes ownership of the
+ /// underlying buffer and gives it back on destruction.
+ class TemporarilyOwnedStringRef {
+ StringRef String;
+ llvm::SaveAndRestore<std::optional<SmallString<256>>> TemporaryLoan;
----------------
benlangmuir wrote:
The specific number is kind of arbitrary, but I meant to say 256 to match the previous code you had.
https://github.com/llvm/llvm-project/pull/113984
More information about the cfe-commits
mailing list