diff options
Diffstat (limited to 'source/core/slang-string.cpp')
| -rw-r--r-- | source/core/slang-string.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index 03de07ee1..c02ba048d 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -134,7 +134,7 @@ namespace Slang if (otherSize > thisSize) return false; - return UnownedStringSlice(begin(), begin() + otherSize) == other; + return head(otherSize) == other; } bool UnownedStringSlice::startsWith(char const* str) const @@ -142,6 +142,17 @@ namespace Slang return startsWith(UnownedTerminatedStringSlice(str)); } + bool UnownedStringSlice::startsWithCaseInsensitive(UnownedStringSlice const& other) const + { + UInt thisSize = getLength(); + UInt otherSize = other.getLength(); + + if (otherSize > thisSize) + return false; + + return head(otherSize).caseInsensitiveEquals(other); + } + bool UnownedStringSlice::endsWith(UnownedStringSlice const& other) const { @@ -474,6 +485,8 @@ namespace Slang { auto oldLength = getLength(); auto textLength = textEnd - textBegin; + if (textLength <= 0) + return; auto newLength = oldLength + textLength; |
