diff options
author | Anna Henningsen <anna@addaleax.net> | 2021-05-23 18:21:18 +0300 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2021-05-31 22:34:52 +0300 |
commit | 18f3ba3674aef389ee58b0f744aa12843168754a (patch) | |
tree | c2f56d7284df6ca41f75cfef8d3f2f418a662b04 /src | |
parent | 3741595289902952b16a17defbce917366c6823f (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')
-rw-r--r-- | src/node_messaging.h | 6 |
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_; |