From 28e1b2e2f1a6bedc835db244226659bfcaa0f068 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 23 May 2021 17:21:18 +0200 Subject: [PATCH] worker: leave TODO comments for using std::variant when possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t use C++17 as a baseline yet, but once we do, we can use `std::variant` to make a few things more performant (and cleaner). There is a similar TODO comment in the crypto source already. PR-URL: https://github.com/nodejs/node/pull/38788 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- src/node_messaging.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node_messaging.h b/src/node_messaging.h index 429a5646b8ada4..799bece3cbd517 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -107,6 +107,9 @@ class Message : public MemoryRetainer { private: MallocedBuffer main_message_buf_; + // TODO(addaleax): Make this a std::variant to save storage size in the common + // case (which is that all of these vectors are empty) once that is available + // with C++17. std::vector> array_buffers_; std::vector> shared_array_buffers_; std::vector> transferables_; @@ -202,6 +205,9 @@ class MessagePortData : public TransferData { // This mutex protects all fields below it, with the exception of // sibling_. mutable Mutex mutex_; + // TODO(addaleax): Make this a std::variant + // once that is available with C++17, because std::shared_ptr comes with + // overhead that is only necessary for BroadcastChannel. std::deque> incoming_messages_; MessagePort* owner_ = nullptr; std::shared_ptr group_;