Skip to content

Commit a67f384

Browse files
committed
Avoid temporary substr in Parser::match
Made-with: Cursor
1 parent 504dc79 commit a67f384

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/core/parser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ char Parser::consume() {
313313
return m_input[m_position++];
314314
}
315315

316+
// Match a literal string at the current position without allocating a temporary substring.
316317
bool Parser::match(const std::string& str) {
317-
if (m_input.substr(m_position, str.length()) == str) {
318+
if (m_input.compare(m_position, str.length(), str) == 0) {
318319
m_position += str.length();
319320
return true;
320321
}

0 commit comments

Comments
 (0)