From c7de1ba9f33c6cd54acb9aba96fb2524b29252f8 Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Tue, 28 Nov 2023 19:16:49 +0000 Subject: [PATCH] Use StringPieces for RE2::Scanner matches 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. --- ext/re2/re2.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/re2/re2.cc b/ext/re2/re2.cc index 4616971..1815bf3 100644 --- a/ext/re2/re2.cc +++ b/ext/re2/re2.cc @@ -359,7 +359,7 @@ static VALUE re2_scanner_scan(VALUE self) { std::vector argv(c->number_of_capturing_groups); std::vector args(c->number_of_capturing_groups); - std::vector matches(c->number_of_capturing_groups); + std::vector matches(c->number_of_capturing_groups); if (c->eof) { return Qnil;