Skip to content

Commit 18f3ba3

Browse files
addaleaxdanielleadams
authored andcommitted
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: #38788 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3741595 commit 18f3ba3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/node_messaging.h

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class Message : public MemoryRetainer {
107107

108108
private:
109109
MallocedBuffer<char> main_message_buf_;
110+
// TODO(addaleax): Make this a std::variant to save storage size in the common
111+
// case (which is that all of these vectors are empty) once that is available
112+
// with C++17.
110113
std::vector<std::shared_ptr<v8::BackingStore>> array_buffers_;
111114
std::vector<std::shared_ptr<v8::BackingStore>> shared_array_buffers_;
112115
std::vector<std::unique_ptr<TransferData>> transferables_;
@@ -202,6 +205,9 @@ class MessagePortData : public TransferData {
202205
// This mutex protects all fields below it, with the exception of
203206
// sibling_.
204207
mutable Mutex mutex_;
208+
// TODO(addaleax): Make this a std::variant<std::shared_ptr, std::unique_ptr>
209+
// once that is available with C++17, because std::shared_ptr comes with
210+
// overhead that is only necessary for BroadcastChannel.
205211
std::deque<std::shared_ptr<Message>> incoming_messages_;
206212
MessagePort* owner_ = nullptr;
207213
std::shared_ptr<SiblingGroup> group_;

0 commit comments

Comments
 (0)