From c024bb0be5c4867586188ce926b00a09ff921c13 Mon Sep 17 00:00:00 2001 From: Leonid Fedorov Date: Tue, 12 Mar 2024 15:39:17 +0000 Subject: [PATCH] extra string copy eliminanated --- utils/funcexp/func_regexp.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/funcexp/func_regexp.cpp b/utils/funcexp/func_regexp.cpp index c1ca36ca2..3da9fc7dd 100644 --- a/utils/funcexp/func_regexp.cpp +++ b/utils/funcexp/func_regexp.cpp @@ -323,16 +323,16 @@ std::string Func_regexp_replace::getStrVal(rowgroup::Row& row, FunctionParm& fp, return param.expression; PCREOptions options(ct); + param.CharsetFix(options); + jp::Regex re(param.pattern, options.flags); - auto replaceWithStr = replaceWith.unsafeStringRef(); + const auto& replaceWithStr = replaceWith.unsafeStringRef(); if (options.conversionIsNeeded) { - replaceWithStr = csConvert(replaceWithStr, options.libraryCharset, options.dataCharset); + const auto& convertedReplaceToken = csConvert(replaceWithStr, options.libraryCharset, options.dataCharset); + return re.replace(param.expression, convertedReplaceToken, "g"); } - param.CharsetFix(options); - - jp::Regex re(param.pattern, options.flags); return re.replace(param.expression, replaceWithStr, "g"); }