diff options
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r-- | src/emscripten-optimizer/istring.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/emscripten-optimizer/istring.h b/src/emscripten-optimizer/istring.h index 74b2c1e4b..8c77c4499 100644 --- a/src/emscripten-optimizer/istring.h +++ b/src/emscripten-optimizer/istring.h @@ -137,14 +137,18 @@ struct IString { bool is() const { return str != nullptr; } bool isNull() const { return str == nullptr; } - bool startsWith(const char *prefix) const { + const char* stripPrefix(const char *prefix) const { const char *ptr = str; while (true) { - if (*prefix == 0) return true; - if (*ptr == 0) return false; - if (*ptr++ != *prefix++) return false; + if (*prefix == 0) return ptr; + if (*ptr == 0) return nullptr; + if (*ptr++ != *prefix++) return nullptr; } } + + bool startsWith(const char *prefix) const { + return stripPrefix(prefix) != nullptr; + } }; } // namespace cashew |