[clang] [clang][modules] Avoid allocations when reading blob paths (PR #113984)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 08:46:42 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;
----------------
jansvoboda11 wrote:

Did you mean 250 specifically, or is that a typo?

https://github.com/llvm/llvm-project/pull/113984


More information about the cfe-commits mailing list