kou commented on code in PR #38873:
URL: https://github.com/apache/arrow/pull/38873#discussion_r1405548776
##########
cpp/src/gandiva/regex_functions_holder_test.cc:
##########
@@ -252,29 +224,25 @@ TEST_F(TestLikeHolder, TestEmptyEscapeChar) {
}
TEST_F(TestLikeHolder, TestMultipleEscapeChar) {
- std::shared_ptr<LikeHolder> like_holder;
-
- auto status = LikeHolder::Make("ab\\_", "\\\\", &like_holder);
+ auto status = LikeHolder::Make("ab\\_", "\\\\").status();
EXPECT_EQ(status.ok(), false) << status.message();
}
class TestILikeHolder : public ::testing::Test {
public:
RE2::Options regex_op;
- FunctionNode BuildILike(std::string pattern) {
+ static FunctionNode BuildILike(std::string pattern) {
Review Comment:
Why do we need this `static`?
I think that we can call this as an instance method in `TEST_F()` without
`static`.
##########
cpp/src/gandiva/regex_functions_holder_test.cc:
##########
@@ -330,16 +289,14 @@ class TestReplaceHolder : public ::testing::Test {
};
TEST_F(TestReplaceHolder, TestMultipleReplace) {
- std::shared_ptr<ReplaceHolder> replace_holder;
-
- auto status = ReplaceHolder::Make("ana", &replace_holder);
- EXPECT_EQ(status.ok(), true) << status.message();
+ auto replace_holder = ReplaceHolder::Make("ana");
+ EXPECT_EQ(replace_holder.ok(), true) << replace_holder.status().message();
Review Comment:
Can we use `EXPECT_OK_AND_ASSIGN()` here?
##########
cpp/src/gandiva/regex_functions_holder.cc:
##########
@@ -132,12 +131,11 @@ Status LikeHolder::Make(const std::string& sql_pattern,
Status::Invalid("Building RE2 pattern '", pcre_pattern,
"' failed with: ", lholder->regex_.error()));
- *holder = std::move(lholder);
- return Status::OK();
+ return std::move(lholder);
Review Comment:
I think that `std::move()` for local variable in `return` isn't needed.
I think that it'll prevent NRVO (Named Return Value Optimization). See also:
https://en.cppreference.com/w/cpp/language/copy_elision#Non-mandatory_copy.2Fmove.28since_C.2B.2B11.29_elision
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]