================
@@ -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:
I think we should switch to `SmallString<0>` so that save and restore is just
swapping a pointer instead of copying 256 bytes and we don't waste the extra
stack space in every caller. If you `reserve(250)` it will only have a single
allocation for the whole compilation.
https://github.com/llvm/llvm-project/pull/113984
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits