From 2f107c8a68fe63d9e27a0cb62348a6d3b3e4d27b Mon Sep 17 00:00:00 2001 From: Kristen Parton Date: Tue, 18 Aug 2015 21:53:36 -0700 Subject: [PATCH] Revert "[folly::gen] Prevent accidental moves in filter()" Summary: This reverts commit aee49bc8a945db9ad6c0ef6a9598ca5c44a4dc8c. Temporarily reverting the previous diff to investigate possible downstream regression. Reviewed By: @yfeldblum Differential Revision: D2359864 --- folly/gen/Base-inl.h | 6 ++---- folly/gen/test/BaseTest.cpp | 9 --------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/folly/gen/Base-inl.h b/folly/gen/Base-inl.h index 23b91973..0c4e92f4 100644 --- a/folly/gen/Base-inl.h +++ b/folly/gen/Base-inl.h @@ -559,8 +559,7 @@ class Filter : public Operator> { template void foreach(Body&& body) const { source_.foreach([&](Value value) { - // NB: Argument not forwarded to avoid accidental move-construction - if (pred_(value)) { + if (pred_(std::forward(value))) { body(std::forward(value)); } }); @@ -569,8 +568,7 @@ class Filter : public Operator> { template bool apply(Handler&& handler) const { return source_.apply([&](Value value) -> bool { - // NB: Argument not forwarded to avoid accidental move-construction - if (pred_(value)) { + if (pred_(std::forward(value))) { return handler(std::forward(value)); } return true; diff --git a/folly/gen/test/BaseTest.cpp b/folly/gen/test/BaseTest.cpp index e97cf6c3..7741b053 100644 --- a/folly/gen/test/BaseTest.cpp +++ b/folly/gen/test/BaseTest.cpp @@ -289,15 +289,6 @@ TEST(Gen, FilterDefault) { } } -TEST(Gen, FilterSink) { - auto actual - = seq(1, 2) - | map([](int x) { return vector{x}; }) - | filter([](vector v) { return !v.empty(); }) - | as(); - EXPECT_FALSE(from(actual) | rconcat | isEmpty); -} - TEST(Gen, Contains) { { auto gen = -- 2.34.1