From 6139fd449c5f73dcabff0879fa2b90724cb4b99e Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Sun, 4 Feb 2018 05:45:43 +0100 Subject: [PATCH] os/bluestore: avoid overhead of std::function in blob_t. Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 28997c1c6b43f71e92799d7b95452c5b4026d989) --- src/os/bluestore/bluestore_types.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index f48f095a096..5df1d401344 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -17,6 +17,7 @@ #include #include +#include #include "include/types.h" #include "include/interval_set.h" #include "include/utime.h" @@ -729,8 +730,10 @@ public: } } - int map(uint64_t x_off, uint64_t x_len, - std::function f) const { + template + int map(uint64_t x_off, uint64_t x_len, F&& f) const { + static_assert(std::is_invocable_r_v); + auto p = extents.begin(); assert(p != extents.end()); while (x_off >= p->length) { @@ -750,9 +753,12 @@ public: } return 0; } + template void map_bl(uint64_t x_off, bufferlist& bl, - std::function f) const { + F&& f) const { + static_assert(std::is_invocable_v); + auto p = extents.begin(); assert(p != extents.end()); while (x_off >= p->length) { -- 2.47.3