Commit 455116f7 authored by TJ Yin's avatar TJ Yin Committed by Facebook Github Bot

replace more folly::Optional::reset by clear inside template

Reviewed By: vitaut

Differential Revision: D20098574

fbshipit-source-id: 409c3c1e7716a38f253fa3d0d8afe615139426cc
parent 4af06cab
...@@ -118,7 +118,7 @@ class Optional { ...@@ -118,7 +118,7 @@ class Optional {
std::is_nothrow_move_constructible<Value>::value) { std::is_nothrow_move_constructible<Value>::value) {
if (src.hasValue()) { if (src.hasValue()) {
construct(std::move(src.value())); construct(std::move(src.value()));
src.clear(); src.reset();
} }
} }
...@@ -157,16 +157,16 @@ class Optional { ...@@ -157,16 +157,16 @@ class Optional {
} }
void assign(const None&) { void assign(const None&) {
clear(); reset();
} }
void assign(Optional&& src) { void assign(Optional&& src) {
if (this != &src) { if (this != &src) {
if (src.hasValue()) { if (src.hasValue()) {
assign(std::move(src.value())); assign(std::move(src.value()));
src.clear(); src.reset();
} else { } else {
clear(); reset();
} }
} }
} }
...@@ -175,7 +175,7 @@ class Optional { ...@@ -175,7 +175,7 @@ class Optional {
if (src.hasValue()) { if (src.hasValue()) {
assign(src.value()); assign(src.value());
} else { } else {
clear(); reset();
} }
} }
...@@ -220,7 +220,7 @@ class Optional { ...@@ -220,7 +220,7 @@ class Optional {
template <class... Args> template <class... Args>
Value& emplace(Args&&... args) { Value& emplace(Args&&... args) {
clear(); reset();
construct(std::forward<Args>(args)...); construct(std::forward<Args>(args)...);
return value(); return value();
} }
...@@ -230,7 +230,7 @@ class Optional { ...@@ -230,7 +230,7 @@ class Optional {
std::is_constructible<Value, std::initializer_list<U>&, Args&&...>::value, std::is_constructible<Value, std::initializer_list<U>&, Args&&...>::value,
Value&>::type Value&>::type
emplace(std::initializer_list<U> ilist, Args&&... args) { emplace(std::initializer_list<U> ilist, Args&&... args) {
clear(); reset();
construct(ilist, std::forward<Args>(args)...); construct(ilist, std::forward<Args>(args)...);
return value(); return value();
} }
......
...@@ -107,7 +107,7 @@ void runKeyExtractCases( ...@@ -107,7 +107,7 @@ void runKeyExtractCases(
{ {
std::pair<Tracked<0> const, Tracked<1>> p{0, 0}; std::pair<Tracked<0> const, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
resetTracking(); resetTracking();
func(sinkFunc, p); func(sinkFunc, p);
// fresh key, value_type const& -> // fresh key, value_type const& ->
...@@ -121,7 +121,7 @@ void runKeyExtractCases( ...@@ -121,7 +121,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<0> const, Tracked<1>> p{0, 0}; std::pair<Tracked<0> const, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
resetTracking(); resetTracking();
func(sinkFunc, std::move(p)); func(sinkFunc, std::move(p));
// fresh key, value_type&& -> // fresh key, value_type&& ->
...@@ -135,7 +135,7 @@ void runKeyExtractCases( ...@@ -135,7 +135,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<0>, Tracked<1>> p{0, 0}; std::pair<Tracked<0>, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
resetTracking(); resetTracking();
func(sinkFunc, p); func(sinkFunc, p);
// fresh key, pair<key_type,mapped_type> const& -> // fresh key, pair<key_type,mapped_type> const& ->
...@@ -149,7 +149,7 @@ void runKeyExtractCases( ...@@ -149,7 +149,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<0>, Tracked<1>> p{0, 0}; std::pair<Tracked<0>, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
resetTracking(); resetTracking();
func(sinkFunc, std::move(p)); func(sinkFunc, std::move(p));
// fresh key, pair<key_type,mapped_type>&& -> // fresh key, pair<key_type,mapped_type>&& ->
...@@ -163,7 +163,7 @@ void runKeyExtractCases( ...@@ -163,7 +163,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<2>, Tracked<3>> p{0, 0}; std::pair<Tracked<2>, Tracked<3>> p{0, 0};
sink.clear(); sink.reset();
resetTracking(); resetTracking();
func(sinkFunc, p); func(sinkFunc, p);
// fresh key, convertible const& -> // fresh key, convertible const& ->
...@@ -198,7 +198,7 @@ void runKeyExtractCases( ...@@ -198,7 +198,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<2>, Tracked<3>> p{0, 0}; std::pair<Tracked<2>, Tracked<3>> p{0, 0};
sink.clear(); sink.reset();
resetTracking(); resetTracking();
func(sinkFunc, std::move(p)); func(sinkFunc, std::move(p));
// fresh key, convertible&& -> // fresh key, convertible&& ->
...@@ -215,7 +215,7 @@ void runKeyExtractCases( ...@@ -215,7 +215,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<0> const, Tracked<1>> p{0, 0}; std::pair<Tracked<0> const, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
sink.emplace(0, 0); sink.emplace(0, 0);
resetTracking(); resetTracking();
func(sinkFunc, p); func(sinkFunc, p);
...@@ -227,7 +227,7 @@ void runKeyExtractCases( ...@@ -227,7 +227,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<0> const, Tracked<1>> p{0, 0}; std::pair<Tracked<0> const, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
sink.emplace(0, 0); sink.emplace(0, 0);
resetTracking(); resetTracking();
func(sinkFunc, std::move(p)); func(sinkFunc, std::move(p));
...@@ -239,7 +239,7 @@ void runKeyExtractCases( ...@@ -239,7 +239,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<0>, Tracked<1>> p{0, 0}; std::pair<Tracked<0>, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
sink.emplace(0, 0); sink.emplace(0, 0);
resetTracking(); resetTracking();
func(sinkFunc, p); func(sinkFunc, p);
...@@ -251,7 +251,7 @@ void runKeyExtractCases( ...@@ -251,7 +251,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<0>, Tracked<1>> p{0, 0}; std::pair<Tracked<0>, Tracked<1>> p{0, 0};
sink.clear(); sink.reset();
sink.emplace(0, 0); sink.emplace(0, 0);
resetTracking(); resetTracking();
func(sinkFunc, std::move(p)); func(sinkFunc, std::move(p));
...@@ -263,7 +263,7 @@ void runKeyExtractCases( ...@@ -263,7 +263,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<2>, Tracked<3>> p{0, 0}; std::pair<Tracked<2>, Tracked<3>> p{0, 0};
sink.clear(); sink.reset();
sink.emplace(0, 0); sink.emplace(0, 0);
resetTracking(); resetTracking();
func(sinkFunc, p); func(sinkFunc, p);
...@@ -281,7 +281,7 @@ void runKeyExtractCases( ...@@ -281,7 +281,7 @@ void runKeyExtractCases(
} }
{ {
std::pair<Tracked<2>, Tracked<3>> p{0, 0}; std::pair<Tracked<2>, Tracked<3>> p{0, 0};
sink.clear(); sink.reset();
sink.emplace(0, 0); sink.emplace(0, 0);
resetTracking(); resetTracking();
func(sinkFunc, std::move(p)); func(sinkFunc, std::move(p));
......
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