diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-03-09 06:22:58 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-03-09 06:22:58 +0000 |
commit | 3e07f8a03d85956013cd9e9b100ac274f44f3f34 (patch) | |
tree | a3e0b34ce17d07d924318c8a235d21fe62039f49 /include | |
parent | ed8ba2e58e6ad9069feeba7bfca60b8873d23743 (diff) | |
download | llvm-3e07f8a03d85956013cd9e9b100ac274f44f3f34.tar.gz llvm-3e07f8a03d85956013cd9e9b100ac274f44f3f34.tar.bz2 llvm-3e07f8a03d85956013cd9e9b100ac274f44f3f34.tar.xz |
Revert "Clean up SmallString a bit"
This reverts commit r203374.
Ambiguities in assign... oh well. I'm just going to revert this and
probably not try to recommit it as it's not terribly important.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203375 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/SmallString.h | 50 | ||||
-rw-r--r-- | include/llvm/ADT/SmallVector.h | 10 | ||||
-rw-r--r-- | include/llvm/DebugInfo/DIContext.h | 3 |
3 files changed, 42 insertions, 21 deletions
diff --git a/include/llvm/ADT/SmallString.h b/include/llvm/ADT/SmallString.h index 740a0a5cd8..e569f54481 100644 --- a/include/llvm/ADT/SmallString.h +++ b/include/llvm/ADT/SmallString.h @@ -28,18 +28,30 @@ public: SmallString() {} /// Initialize from a StringRef. - /*implicit*/ SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {} + SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {} /// Initialize with a range. template<typename ItTy> SmallString(ItTy S, ItTy E) : SmallVector<char, InternalLen>(S, E) {} + // Note that in order to add new overloads for append & assign, we have to + // duplicate the inherited versions so as not to inadvertently hide them. + /// @} /// @name String Assignment /// @{ - // Provide assign from SmallVectorImpl<char> - using SmallVectorImpl<char>::assign; + /// Assign from a repeated element. + void assign(size_t NumElts, char Elt) { + this->SmallVectorImpl<char>::assign(NumElts, Elt); + } + + /// Assign from an iterator pair. + template<typename in_iter> + void assign(in_iter S, in_iter E) { + this->clear(); + SmallVectorImpl<char>::append(S, E); + } /// Assign from a StringRef. void assign(StringRef RHS) { @@ -53,7 +65,20 @@ public: SmallVectorImpl<char>::append(RHS.begin(), RHS.end()); } - using SmallVectorImpl<char>::append; + /// @} + /// @name String Concatenation + /// @{ + + /// Append from an iterator pair. + template<typename in_iter> + void append(in_iter S, in_iter E) { + SmallVectorImpl<char>::append(S, E); + } + + void append(size_t NumInputs, char Elt) { + SmallVectorImpl<char>::append(NumInputs, Elt); + } + /// Append from a StringRef. void append(StringRef RHS) { @@ -69,6 +94,12 @@ public: /// @name String Comparison /// @{ + /// Check for string equality. This is more efficient than compare() when + /// the relative ordering of inequal strings isn't needed. + bool equals(StringRef RHS) const { + return str().equals(RHS); + } + /// Check for string equality, ignoring case. bool equals_lower(StringRef RHS) const { return str().equals_lower(RHS); @@ -245,9 +276,6 @@ public: /// Implicit conversion to StringRef. operator StringRef() const { return str(); } - // Provide op= for SmallVectorImpl<char> - using SmallVectorImpl<char>::operator=; - // Extra operators. const SmallString &operator=(StringRef RHS) { this->clear(); @@ -255,15 +283,9 @@ public: } SmallString &operator+=(StringRef RHS) { - append(RHS.begin(), RHS.end()); + this->append(RHS.begin(), RHS.end()); return *this; } - - SmallString &operator+=(const SmallVectorImpl<char> &RHS) { - append(RHS.begin(), RHS.end()); - return *this; - } - SmallString &operator+=(char C) { this->push_back(C); return *this; diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index e5e53d1dd6..2a5168c261 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -451,12 +451,10 @@ public: void assign(unsigned NumElts, const T &Elt) { clear(); - append(NumElts, Elt); - } - - template <typename in_iter> void assign(in_iter S, in_iter E) { - clear(); - append(S, E); + if (this->capacity() < NumElts) + this->grow(NumElts); + this->setEnd(this->begin()+NumElts); + std::uninitialized_fill(this->begin(), this->end(), Elt); } iterator erase(iterator I) { diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index c20f1ea450..f04dc001f4 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -50,7 +50,8 @@ public: bool operator==(const DILineInfo &RHS) const { return Line == RHS.Line && Column == RHS.Column && - FileName == RHS.FileName && FunctionName == RHS.FunctionName; + FileName.equals(RHS.FileName) && + FunctionName.equals(RHS.FunctionName); } bool operator!=(const DILineInfo &RHS) const { return !(*this == RHS); |