bkietz commented on a change in pull request #8507:
URL: https://github.com/apache/arrow/pull/8507#discussion_r512773517



##########
File path: cpp/src/arrow/dataset/filter.cc
##########
@@ -1337,7 +1351,11 @@ Result<std::shared_ptr<RecordBatch>> 
TreeEvaluator::Filter(
   return batch->Slice(0, 0);
 }
 
-std::shared_ptr<Expression> scalar(bool value) { return 
scalar(MakeScalar(value)); }
+const std::shared_ptr<Expression>& scalar(bool value) {
+  static auto true_ = scalar(MakeScalar(true));
+  static auto false_ = scalar(MakeScalar(false));
+  return value ? true_ : false_;
+}

Review comment:
       Just results in slightly less allocator churn for the very common case 
of a boolean ScalarExpression, since we produce only two permanent instances 
rather than one per invocation of `scalar(bool)`




----------------------------------------------------------------
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:
[email protected]


Reply via email to