From 28997c1c6b43f71e92799d7b95452c5b4026d989 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 --- 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 604360c03c4ab..ece69413b1955 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" @@ -730,8 +731,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) { @@ -751,9 +754,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.39.5