diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-12-05 15:24:57 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-12-06 18:30:49 +0000 |
commit | 28fbd13e22935483d9ebcf2f088681f3d649cf2a (patch) | |
tree | 7e78f85e99f55b67cc39781b5d2591b5ad7dfded /src/plugins/platforms/xcb | |
parent | 6fed5cf4e28927bae88c1f18cad8a3ee0eedbc5b (diff) |
xcb: use a more efficient unique_ptr instantiation
Wrap std::free() in a function object, to avoid having to carry around
state (the function pointer) inside unique_ptr objects. This shrinks
unique_ptrs back to sizeof(void*).
Change-Id: I32a711192c5485dc04e3b36a1ddabf02d1e9d4f9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 725c01f77d..ded11525c1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -757,16 +757,18 @@ private: #define Q_XCB_REPLY_CONNECTION_ARG(connection, ...) connection +struct QStdFreeDeleter { + void operator()(void *p) const Q_DECL_NOTHROW { return std::free(p); } +}; + #define Q_XCB_REPLY(call, ...) \ - std::unique_ptr<call##_reply_t, decltype(std::free) *>( \ - call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call(__VA_ARGS__), nullptr), \ - std::free \ + std::unique_ptr<call##_reply_t, QStdFreeDeleter>( \ + call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call(__VA_ARGS__), nullptr) \ ) #define Q_XCB_REPLY_UNCHECKED(call, ...) \ - std::unique_ptr<call##_reply_t, decltype(std::free) *>( \ - call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call##_unchecked(__VA_ARGS__), nullptr), \ - std::free \ + std::unique_ptr<call##_reply_t, QStdFreeDeleter>( \ + call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call##_unchecked(__VA_ARGS__), nullptr) \ ) template <typename T> |