[clang] [Clang][TableGen] Use StringRef::str() instead of std::string() cast (PR #113645)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 25 22:34:11 PDT 2024


================
@@ -54,19 +54,18 @@ class FlattenedSpelling {
   const Record &OriginalSpelling;
 
 public:
-  FlattenedSpelling(const std::string &Variety, const std::string &Name,
+  FlattenedSpelling(const std::string &Variety, StringRef Name,
                     const std::string &Namespace, bool KnownToGCC,
----------------
kazutakahirata wrote:

Could you make all of `const std::string &` here into `StringRef`?  Partly for consistency among the parameters, partly for performance.  IIUC, users below pass string literals like `"GNU"` and `"CXX11"`.  That means that we create temporary instances of `std::string` there, pass them to this constructor by const reference, and then create duplicate instances of `std::string`.  If you could create a PR just for the changes to `FlattenSpelling`, that would be greatly appreciated.  Thanks!

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


More information about the cfe-commits mailing list