From 5b909beeec178f338be997830b6c31a80cda7a93 Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Thu, 4 Aug 2022 10:53:26 -0700 Subject: [PATCH] Explicitly instantiate matchee std::string in MatchesRegex If this ever turns out to be a performance issue, we could use std::conditional and std::is_same to avoid copying std::strings. Fixes #3949 PiperOrigin-RevId: 465353572 Change-Id: If2d691bccb626c692c87e006df5afe88a4ed1542 --- googletest/include/gtest/gtest-matchers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index bffa00c5..4a60b0d0 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -842,7 +842,7 @@ class MatchesRegexMatcher { template bool MatchAndExplain(const MatcheeStringType& s, MatchResultListener* /* listener */) const { - const std::string& s2(s); + const std::string s2(s); return full_match_ ? RE::FullMatch(s2, *regex_) : RE::PartialMatch(s2, *regex_); }