summaryrefslogtreecommitdiff
path: root/source/core
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-12-13 12:26:36 -0800
committerGitHub <noreply@github.com>2018-12-13 12:26:36 -0800
commit970b58a209e06afc7bd104e4701abfbb055f7c4d (patch)
treecf57d89d6292d2f471c286b1b1c8d62d6b68bf84 /source/core
parent8d13c06ab51f4993f5c56772e83fba3c384674df (diff)
parent822ed708364b257b7d2f61ecb8a51a4c96f7edaa (diff)
Merge branch 'master' into dictfix
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-string.cpp17
-rw-r--r--source/core/slang-string.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp
index 648249b2c..28acde6ac 100644
--- a/source/core/slang-string.cpp
+++ b/source/core/slang-string.cpp
@@ -45,6 +45,23 @@ namespace Slang
// UnownedStringSlice
+ bool UnownedStringSlice::startsWith(UnownedStringSlice const& other) const
+ {
+ UInt thisSize = size();
+ UInt otherSize = other.size();
+
+ if (otherSize > thisSize)
+ return false;
+
+ return UnownedStringSlice(begin(), begin() + otherSize) == other;
+ }
+
+ bool UnownedStringSlice::startsWith(char const* str) const
+ {
+ return startsWith(UnownedTerminatedStringSlice(str));
+ }
+
+
bool UnownedStringSlice::endsWith(UnownedStringSlice const& other) const
{
UInt thisSize = size();
diff --git a/source/core/slang-string.h b/source/core/slang-string.h
index 435e2b29b..5a20d8b75 100644
--- a/source/core/slang-string.h
+++ b/source/core/slang-string.h
@@ -133,6 +133,8 @@ namespace Slang
return !(*this == other);
}
+ bool startsWith(UnownedStringSlice const& other) const;
+ bool startsWith(char const* str) const;
bool endsWith(UnownedStringSlice const& other) const;
bool endsWith(char const* str) const;