Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2021-05-23 18:21:18 +0300
committerAnna Henningsen <anna@addaleax.net>2021-05-24 15:53:24 +0300
commit28e1b2e2f1a6bedc835db244226659bfcaa0f068 (patch)
tree77484f73275fb545dfc2d11630a595d9d029153b /src/node_messaging.h
parente9e851f4b687d39cecd7ae5de8be0f219bc415c4 (diff)
worker: leave TODO comments for using std::variant when possible
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 <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_messaging.h')
-rw-r--r--src/node_messaging.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_messaging.h b/src/node_messaging.h
index 429a5646b8a..799bece3cbd 100644
--- a/src/node_messaging.h
+++ b/src/node_messaging.h
@@ -107,6 +107,9 @@ class Message : public MemoryRetainer {
private:
MallocedBuffer<char> 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<std::shared_ptr<v8::BackingStore>> array_buffers_;
std::vector<std::shared_ptr<v8::BackingStore>> shared_array_buffers_;
std::vector<std::unique_ptr<TransferData>> 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<std::shared_ptr, std::unique_ptr>
+ // once that is available with C++17, because std::shared_ptr comes with
+ // overhead that is only necessary for BroadcastChannel.
std::deque<std::shared_ptr<Message>> incoming_messages_;
MessagePort* owner_ = nullptr;
std::shared_ptr<SiblingGroup> group_;