diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-11-07 09:45:08 -0800 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-11-07 10:54:06 -0800 |
| commit | 722105feb1f11ea727af52bc5a484ddf4320e74d (patch) | |
| tree | 86fce77d485f5167a8836551315d7829ac90ea9e | |
| parent | 5c220292d6ac2674942bb5f1bb09fe1817151c11 (diff) | |
Add a comparison operator to UnownedStringSlice
This is to allow me to compare for particular names in my de-mangling logic in `emit.cpp`.
| -rw-r--r-- | source/core/slang-string.h | 16 |
1 files changed, 16 insertions, 0 deletions
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; |
