kangkaisen commented on a change in pull request #3439: URL: https://github.com/apache/incubator-doris/pull/3439#discussion_r418492786
########## File path: be/src/exprs/string_functions.cpp ########## @@ -212,6 +212,28 @@ StringVal StringFunctions::rpad( } return result; } + +StringVal StringFunctions::append_trailing_char_if_absent(doris_udf::FunctionContext* context, + const doris_udf::StringVal& str, const doris_udf::StringVal& trailing_char) { + if (str.is_null || trailing_char.is_null) { + return StringVal::null(); + } + if (str.len == 0) { + return trailing_char; + } + if (str.ptr[str.len-1] == trailing_char.ptr[0]) { + return str; + } + + StringVal result(context, str.len + trailing_char.len); + if (UNLIKELY(result.is_null)) { Review comment: In fact, FreePool allocate never return null. So `result.is_null` check is unnecessary. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org