Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/19797#discussion_r153186151 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala --- @@ -334,7 +334,7 @@ case class RegExpReplace(subject: Expression, regexp: Expression, rep: Expressio ctx.addMutableState("String", termLastReplacement, s"${termLastReplacement} = null;") ctx.addMutableState("UTF8String", termLastReplacementInUTF8, s"${termLastReplacementInUTF8} = null;") - ctx.addMutableState(classNameStringBuffer, + ctx.reuseOrAddMutableState(classNameStringBuffer, termResult, s"${termResult} = new $classNameStringBuffer();") --- End diff -- seems we can just create the string buffer every time, the overhead is small.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org