diff options
author | Heejin Ahn <aheejin@users.noreply.github.com> | 2018-01-29 15:55:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 15:55:19 -0800 |
commit | 52f115f8ea66467d8c500fa9b03d2deb98eaafa2 (patch) | |
tree | 8fd2d9f298d8e4aca57962d928799fdf31247968 /src/emscripten-optimizer | |
parent | b1d24f5c552ccb0c3076e252b893990340d6016e (diff) | |
download | binaryen-52f115f8ea66467d8c500fa9b03d2deb98eaafa2.tar.gz binaryen-52f115f8ea66467d8c500fa9b03d2deb98eaafa2.tar.bz2 binaryen-52f115f8ea66467d8c500fa9b03d2deb98eaafa2.zip |
Add startsWith function to IString (#1393)
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r-- | src/emscripten-optimizer/istring.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/emscripten-optimizer/istring.h b/src/emscripten-optimizer/istring.h index b991159e5..74b2c1e4b 100644 --- a/src/emscripten-optimizer/istring.h +++ b/src/emscripten-optimizer/istring.h @@ -136,6 +136,15 @@ struct IString { bool is() const { return str != nullptr; } bool isNull() const { return str == nullptr; } + + bool startsWith(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; + } + } }; } // namespace cashew |