Pass scalar types to callback by value.
On my machine this consistently improves
CallbackPerfTest.SingleThreadNoPostTaskPingPong from 45ns to 40ns per iteration.
Test: out/Default/ipc_perftests --gtest_filter="CallbackPerfTest.SingleThread*"
Let SingleThreadPostTaskPingPong run as well for warm up.
Change-Id: I59a6e573ddd9dbd44a55146e94dc8f09be48319e
Reviewed-on: https://chromium-review.googlesource.com/732303
Commit-Queue: Vladislav Kuzkokov <vkuzkokov@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514946}
CrOS-Libchrome-Original-Commit: 6d208e1cee4179c87775f26a7971d3f7f466fce7
diff --git a/base/bind_internal.h b/base/bind_internal.h
index c19f759..172ce53 100644
--- a/base/bind_internal.h
+++ b/base/bind_internal.h
@@ -308,7 +308,8 @@
template <typename StorageType, typename R, typename... UnboundArgs>
struct Invoker<StorageType, R(UnboundArgs...)> {
- static R RunOnce(BindStateBase* base, UnboundArgs&&... unbound_args) {
+ static R RunOnce(BindStateBase* base,
+ PassingTraitsType<UnboundArgs>... unbound_args) {
// Local references to make debugger stepping easier. If in a debugger,
// you really want to warp ahead and step through the
// InvokeHelper<>::MakeItSo() call below.
@@ -321,7 +322,8 @@
std::forward<UnboundArgs>(unbound_args)...);
}
- static R Run(BindStateBase* base, UnboundArgs&&... unbound_args) {
+ static R Run(BindStateBase* base,
+ PassingTraitsType<UnboundArgs>... unbound_args) {
// Local references to make debugger stepping easier. If in a debugger,
// you really want to warp ahead and step through the
// InvokeHelper<>::MakeItSo() call below.