Skip to content

Commit

Permalink
Use StringPieces for RE2::Scanner matches
Browse files Browse the repository at this point in the history
Rather than allocating new strings when consuming matches for
`RE2::Scanner#scan`, use `StringPiece`s (actually `absl::string_view`s
in newer versions of RE2) to refer to the original input string instead.
  • Loading branch information
mudge committed Nov 28, 2023
1 parent 427ffb0 commit c7de1ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/re2/re2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static VALUE re2_scanner_scan(VALUE self) {

std::vector<RE2::Arg> argv(c->number_of_capturing_groups);
std::vector<RE2::Arg*> args(c->number_of_capturing_groups);
std::vector<std::string> matches(c->number_of_capturing_groups);
std::vector<re2::StringPiece> matches(c->number_of_capturing_groups);

if (c->eof) {
return Qnil;
Expand Down

0 comments on commit c7de1ba

Please sign in to comment.