Skip to content

Commit

Permalink
worker: leave TODO comments for using std::variant when possible
Browse files Browse the repository at this point in the history
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: #38788
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
addaleax authored and danielleadams committed May 31, 2021
1 parent 3741595 commit 18f3ba3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/node_messaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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_;
Expand Down

0 comments on commit 18f3ba3

Please sign in to comment.