@@ -227,17 +227,43 @@ bool OrImpl::Equals(const Expression& expr) const {
227227}
228228
229229// Implementation of Predicate static factory methods
230- std::shared_ptr<Predicate> Predicate::AlwaysTrue () { return True::Instance (); }
230+ const std::shared_ptr<Predicate>& Predicate::AlwaysTrue () {
231+ static const std::shared_ptr<Predicate> instance = True::Instance ();
232+ return instance;
233+ }
231234
232- std::shared_ptr<Predicate> Predicate::AlwaysFalse () { return False::Instance (); }
235+ const std::shared_ptr<Predicate>& Predicate::AlwaysFalse () {
236+ static const std::shared_ptr<Predicate> instance = False::Instance ();
237+ return instance;
238+ }
233239
234240std::shared_ptr<Predicate> Predicate::And (std::shared_ptr<Predicate> left,
235241 std::shared_ptr<Predicate> right) {
242+ /*
243+ auto left_op = left->op();
244+ auto right_op = right->op();
245+ if (left_op == Operation::kFalse || right_op == Operation::kFalse) {
246+ return False::Instance();
247+ }
248+ if (left_op == Operation::kTrue && right_op == Operation::kTrue) {
249+ return left;
250+ }
251+ */
236252 return std::make_shared<AndImpl>(std::move (left), std::move (right));
237253}
238254
239255std::shared_ptr<Predicate> Predicate::Or (std::shared_ptr<Predicate> left,
240256 std::shared_ptr<Predicate> right) {
257+ /*
258+ auto left_op = left->op();
259+ auto right_op = right->op();
260+ if (left_op == Operation::kTrue || right_op == Operation::kTrue) {
261+ return False::Instance();
262+ }
263+ if (left_op == Operation::kFalse && right_op == Operation::kFalse) {
264+ return left;
265+ }
266+ */
241267 return std::make_shared<OrImpl>(std::move (left), std::move (right));
242268}
243269
0 commit comments