Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/ADT/SmallString.h
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | const char* c_str() { | ||||
this->push_back(0); | this->push_back(0); | ||||
this->pop_back(); | this->pop_back(); | ||||
return this->data(); | return this->data(); | ||||
} | } | ||||
/// Implicit conversion to StringRef. | /// Implicit conversion to StringRef. | ||||
operator StringRef() const { return str(); } | operator StringRef() const { return str(); } | ||||
explicit operator std::string() const { return str().str(); } | explicit operator std::string() const { | ||||
MaskRay: The comment is redundant, because the code self explains. | |||||
It's the same in StringRef, but I agree! JDevlieghere: It's the same in StringRef, but I agree! | |||||
return std::string(this->begin(), this->size()); | |||||
craig.topperUnsubmitted Not Done ReplyInline ActionsI'm late here, but that should probably be this->data() instead of this->begin(). It does the same thing in this case, but begin() returns an "iterator" while data() returns a pointer. And the constructor that's being called is defined as taking a pointer and size. craig.topper: I'm late here, but that should probably be this->data() instead of this->begin(). It does the… | |||||
JDevlieghereAuthorUnsubmitted Thanks Craig! I've fixed it for the std::string and llvm::StringRef case above. To github.com:llvm/llvm-project.git cfebd777422..a5f479473b2 master -> master JDevlieghere: Thanks Craig! I've fixed it for the `std::string` and `llvm::StringRef` case above.
```
To… | |||||
} | |||||
// Extra operators. | // Extra operators. | ||||
const SmallString &operator=(StringRef RHS) { | const SmallString &operator=(StringRef RHS) { | ||||
this->clear(); | this->clear(); | ||||
return *this += RHS; | return *this += RHS; | ||||
} | } | ||||
SmallString &operator+=(StringRef RHS) { | SmallString &operator+=(StringRef RHS) { | ||||
Show All 12 Lines |
The comment is redundant, because the code self explains.