summaryrefslogtreecommitdiffstats
path: root/source/core/slang-string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-string.cpp')
-rw-r--r--source/core/slang-string.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp
index bcf5853d5..3ce4c7ec9 100644
--- a/source/core/slang-string.cpp
+++ b/source/core/slang-string.cpp
@@ -1,6 +1,8 @@
#include "slang-string.h"
#include "slang-text-io.h"
+#include "slang-char-util.h"
+
namespace Slang
{
// TODO: this belongs in a different file:
@@ -12,11 +14,6 @@ namespace Slang
throw InternalError(message);
}
- SLANG_FORCE_INLINE static bool _isWhiteSpace(char c)
- {
- return c == ' ' || c == '\t';
- }
-
// OSString
OSString::OSString()
@@ -112,11 +109,20 @@ namespace Slang
const char* start = m_begin;
const char* end = m_end;
- while (start < end && _isWhiteSpace(*start)) start++;
- while (end > start && _isWhiteSpace(end[-1])) end--;
+ while (start < end && CharUtil::isHorizontalWhitespace(*start)) start++;
+ while (end > start && CharUtil::isHorizontalWhitespace(end[-1])) end--;
return UnownedStringSlice(start, end);
}
+ UnownedStringSlice UnownedStringSlice::trim(char c) const
+ {
+ const char* start = m_begin;
+ const char* end = m_end;
+
+ while (start < end && *start == c) start++;
+ while (end > start && end[-1] == c) end--;
+ return UnownedStringSlice(start, end);
+ }
// StringSlice