Commit 4ae89dde authored by Tom Jackson's avatar Tom Jackson Committed by Facebook Github Bot

Rephrase Optional usage to quite warnings

Reviewed By: yfeldblum

Differential Revision: D5105818

fbshipit-source-id: e3926a0c70a68855e0180bdd44cb0ec76e66bb94
parent e51e7780
...@@ -1866,8 +1866,8 @@ class Reduce : public Operator<Reduce<Reducer>> { ...@@ -1866,8 +1866,8 @@ class Reduce : public Operator<Reduce<Reducer>> {
static_assert(!Source::infinite, "Cannot reduce infinite source"); static_assert(!Source::infinite, "Cannot reduce infinite source");
Optional<StorageType> accum; Optional<StorageType> accum;
source | [&](Value v) { source | [&](Value v) {
if (accum.hasValue()) { if (auto target = accum.get_pointer()) {
accum = reducer_(std::move(accum.value()), std::forward<Value>(v)); *target = reducer_(std::move(*target), std::forward<Value>(v));
} else { } else {
accum = std::forward<Value>(v); accum = std::forward<Value>(v);
} }
...@@ -1990,10 +1990,13 @@ class Min : public Operator<Min<Selector, Comparer>> { ...@@ -1990,10 +1990,13 @@ class Min : public Operator<Min<Selector, Comparer>> {
Optional<Key> minKey; Optional<Key> minKey;
source | [&](Value v) { source | [&](Value v) {
Key key = selector_(asConst(v)); // so that selector_ cannot mutate v Key key = selector_(asConst(v)); // so that selector_ cannot mutate v
if (!minKey.hasValue() || comparer_(key, minKey.value())) { if (auto lastKey = minKey.get_pointer()) {
minKey = std::move(key); if (!comparer_(key, *lastKey)) {
min = std::forward<Value>(v); return;
}
} }
minKey = std::move(key);
min = std::forward<Value>(v);
}; };
return min; return min;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment