[compiler-rt] d791f0c - [ORC-RT] Add equality/inequality comparison to string_view.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 1 11:26:14 PDT 2021
Author: Lang Hames
Date: 2021-06-01T11:24:19-07:00
New Revision: d791f0c2199e47e63e1dd95da2e78518d574bad2
URL: https://github.com/llvm/llvm-project/commit/d791f0c2199e47e63e1dd95da2e78518d574bad2
DIFF: https://github.com/llvm/llvm-project/commit/d791f0c2199e47e63e1dd95da2e78518d574bad2.diff
LOG: [ORC-RT] Add equality/inequality comparison to string_view.
Added:
Modified:
compiler-rt/lib/orc/adt.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/orc/adt.h b/compiler-rt/lib/orc/adt.h
index b7d2174bc197e..33b731082f88f 100644
--- a/compiler-rt/lib/orc/adt.h
+++ b/compiler-rt/lib/orc/adt.h
@@ -84,6 +84,21 @@ class string_view {
constexpr size_type size() const noexcept { return Size; }
constexpr bool empty() const noexcept { return Size == 0; }
+ friend bool operator==(const string_view &LHS, const string_view &RHS) {
+ if (LHS.Size != RHS.Size)
+ return false;
+ if (LHS.Data == RHS.Data)
+ return true;
+ for (size_t I = 0; I != LHS.Size; ++I)
+ if (LHS.Data[I] != RHS.Data[I])
+ return false;
+ return true;
+ }
+
+ friend bool operator!=(const string_view &LHS, const string_view &RHS) {
+ return !(LHS == RHS);
+ }
+
private:
const char *Data = nullptr;
size_type Size = 0;
More information about the llvm-commits
mailing list