Skip to content

Commit

Permalink
Reduce allocations in ParserBuilder::waitForInput.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Nov 20, 2023
1 parent 79a969c commit 30626b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class ParserBuilder {
* @param error_msg message to report with parse error if end-of-data is reached
* @param location location associated with the operation.
*/
void waitForInput(const Expression& min, const std::string& error_msg, const Meta& location);
void waitForInput(const Expression& min, std::string_view error_msg, const Meta& location);

/**
* Generates code that ensures that either a minimum amount of data is
Expand All @@ -337,7 +337,7 @@ class ParserBuilder {
* @param error_msg message to report with parse error if end-of-data is reached
* @param location location associated with the operation
*/
void waitForInput(const std::string& error_msg, const Meta& location);
void waitForInput(std::string_view error_msg, const Meta& location);

/**
* Generates code that waits for either more input becoming available or
Expand Down
4 changes: 2 additions & 2 deletions spicy/toolchain/src/compiler/codegen/parser-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,7 @@ Expression ParserBuilder::atEod() {
return builder::call("spicy_rt::atEod", {state().data, state().cur, _filters(state())});
}

void ParserBuilder::waitForInput(const std::string& error_msg, const Meta& location) {
void ParserBuilder::waitForInput(std::string_view error_msg, const Meta& location) {
builder()->addCall("spicy_rt::waitForInput", {state().data, state().cur, builder::string_literal(error_msg),
builder::expression(location), _filters(state())});
}
Expand All @@ -2378,7 +2378,7 @@ Expression ParserBuilder::waitForInputOrEod(const Expression& min) {
return builder::call("spicy_rt::waitForInputOrEod", {state().data, state().cur, min, _filters(state())});
}

void ParserBuilder::waitForInput(const Expression& min, const std::string& error_msg, const Meta& location) {
void ParserBuilder::waitForInput(const Expression& min, std::string_view error_msg, const Meta& location) {
builder()->addCall("spicy_rt::waitForInput", {state().data, state().cur, min, builder::string_literal(error_msg),
builder::expression(location), _filters(state())});
}
Expand Down

0 comments on commit 30626b9

Please sign in to comment.