From 1bbe128af7ff5f28c024e5a7afb77906f7386209 Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Sun, 21 Jan 2024 18:39:26 +0000 Subject: [PATCH] Avoid an unnecessary StringPiece Rather than relying on re2::StringPiece (or absl::string_view) to implement << when inspecting MatchData, use the much simpler write function. --- ext/re2/re2.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/re2/re2.cc b/ext/re2/re2.cc index 475d750..b5463fe 100644 --- a/ext/re2/re2.cc +++ b/ext/re2/re2.cc @@ -743,8 +743,9 @@ static VALUE re2_matchdata_inspect(const VALUE self) { if (match == Qnil) { output << "nil"; } else { - output << "\"" << re2::StringPiece(RSTRING_PTR(match), - RSTRING_LEN(match)) << "\""; + output << "\""; + output.write(RSTRING_PTR(match), RSTRING_LEN(match)); + output << "\""; } }