From d791f0c2199e47e63e1dd95da2e78518d574bad2 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Mon, 31 May 2021 15:25:13 -0700 Subject: [PATCH] [ORC-RT] Add equality/inequality comparison to string_view. --- compiler-rt/lib/orc/adt.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compiler-rt/lib/orc/adt.h b/compiler-rt/lib/orc/adt.h index b7d2174bc197..33b731082f88 100644 --- a/compiler-rt/lib/orc/adt.h +++ b/compiler-rt/lib/orc/adt.h @@ -84,6 +84,21 @@ public: 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;