Skip to content

Commit 52f115f

Browse files
authored
Add startsWith function to IString (#1393)
1 parent b1d24f5 commit 52f115f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/emscripten-optimizer/istring.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ struct IString {
136136

137137
bool is() const { return str != nullptr; }
138138
bool isNull() const { return str == nullptr; }
139+
140+
bool startsWith(const char *prefix) const {
141+
const char *ptr = str;
142+
while (true) {
143+
if (*prefix == 0) return true;
144+
if (*ptr == 0) return false;
145+
if (*ptr++ != *prefix++) return false;
146+
}
147+
}
139148
};
140149

141150
} // namespace cashew

0 commit comments

Comments
 (0)