[PATCH] make SmallString::str() return std::string

David Blaikie dblaikie at gmail.com
Fri Nov 21 12:27:56 PST 2014


(posting this with full context would help make it easier to see/review in Phab)

================
Comment at: include/llvm/ADT/SmallString.h:100
@@ -99,3 +99,3 @@
   bool equals(StringRef RHS) const {
-    return str().equals(RHS);
+    return StringRef().equals(RHS);
   }
----------------
This doesn't look correct at all - that's comparing RHS to a default-constructed StringRef (the empty string). (similarly for the other functions here)

================
Comment at: include/llvm/ADT/Twine.h:142
@@ -137,2 +141,3 @@
       const std::string *stdString;
       const StringRef *stringRef;
+      const SmallVectorImpl<char> *smallString;
----------------
Might make more sense to represent many of these as a const StringRef value (then we wouldn't need so many variants - just build a StringRef from a std::string or a SmallVectorImpl<char>, etc... ) rather than pointers to the actual objects - just pointing straight into the buffer (& storing the length) would be simpler.

http://reviews.llvm.org/D6336






More information about the llvm-commits mailing list