From 722105feb1f11ea727af52bc5a484ddf4320e74d Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 7 Nov 2017 09:45:08 -0800 Subject: Add a comparison operator to UnownedStringSlice This is to allow me to compare for particular names in my de-mangling logic in `emit.cpp`. --- source/core/slang-string.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/core/slang-string.h b/source/core/slang-string.h index 0808d9715..a0f2b48a1 100644 --- a/source/core/slang-string.h +++ b/source/core/slang-string.h @@ -154,6 +154,22 @@ namespace Slang return endData; } + UInt size() const + { + return endData - beginData; + } + + bool operator==(UnownedStringSlice const& other) + { + return size() == other.size() + && memcmp(begin(), other.begin(), size()) == 0; + } + + bool operator==(char const* str) + { + return (*this) == UnownedStringSlice(str, str + strlen(str)); + } + private: char const* beginData; char const* endData; -- cgit v1.2.3