Commit a8218a39 authored by Hannes Roth's avatar Hannes Roth Committed by Sara Golemon

(Wangle) Optimize empty continuation

Summary: It should remove one malloc as per the task.

Test Plan: `fbconfig folly/wangle && fbmake runtests` Also, `--clang`.

Reviewed By: davejwatson@fb.com

Subscribers: fugalh

FB internal diff: D1498331

Tasks: 4913277
parent 65902504
......@@ -29,6 +29,11 @@
namespace folly { namespace wangle { namespace detail {
// As of GCC 4.8.1, the std::function in libstdc++ optimizes only for pointers
// to functions, using a helper avoids a call to malloc.
template<typename T>
void empty_callback(Try<T>&&) { }
/** The shared state object for Future and Promise. */
template<typename T>
class State {
......@@ -107,7 +112,7 @@ class State {
// Called by a destructing Future
void detachFuture() {
if (!callback_) {
setCallback([](Try<T>&&) {});
setCallback(empty_callback<T>);
}
activate();
detachOne();
......
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