diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/StringRef.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Support/StringRef.cpp | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/StringRef.cpp b/contrib/llvm-project/llvm/lib/Support/StringRef.cpp index 104482de4ad7..4bafc4ec7181 100644 --- a/contrib/llvm-project/llvm/lib/Support/StringRef.cpp +++ b/contrib/llvm-project/llvm/lib/Support/StringRef.cpp @@ -12,7 +12,6 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/edit_distance.h" -#include "llvm/Support/Error.h" #include <bitset> using namespace llvm; @@ -373,16 +372,11 @@ void StringRef::split(SmallVectorImpl<StringRef> &A, char Separator, size_t StringRef::count(StringRef Str) const { size_t Count = 0; size_t N = Str.size(); - if (!N || N > Length) + if (N > Length) return 0; - for (size_t i = 0, e = Length - N + 1; i < e;) { - if (substr(i, N).equals(Str)) { + for (size_t i = 0, e = Length - N + 1; i != e; ++i) + if (substr(i, N).equals(Str)) ++Count; - i += N; - } - else - ++i; - } return Count; } @@ -588,11 +582,8 @@ bool StringRef::getAsInteger(unsigned Radix, APInt &Result) const { bool StringRef::getAsDouble(double &Result, bool AllowInexact) const { APFloat F(0.0); - auto StatusOrErr = F.convertFromString(*this, APFloat::rmNearestTiesToEven); - if (errorToBool(StatusOrErr.takeError())) - return true; - - APFloat::opStatus Status = *StatusOrErr; + APFloat::opStatus Status = + F.convertFromString(*this, APFloat::rmNearestTiesToEven); if (Status != APFloat::opOK) { if (!AllowInexact || !(Status & APFloat::opInexact)) return true; |
