diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-09-23 20:26:30 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-09-26 01:27:35 +0300 |
commit | d102a85cd9d55342ec6ad46a274d24ae43c85ea5 (patch) | |
tree | 97b7c21c965265f949edb52f2936b70cfe8b4471 /src/node_messaging.cc | |
parent | 3ea05883c8dcf69e2fa5ffc73556dda51c16e228 (diff) |
src: simplify `MessagePort` construction code a bit
Using `ASSIGN_OR_RETURN_UNWRAP` would return if the
created `MessagePort` object had no internal fields.
That would be a bug, so switch to a checked conversion instead.
PR-URL: https://github.com/nodejs/node/pull/23036
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_messaging.cc')
-rw-r--r-- | src/node_messaging.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 20e0c7673b8..bb7344503e7 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -483,14 +483,14 @@ MessagePort* MessagePort::New( Local<Function> ctor; if (!GetMessagePortConstructor(env, context).ToLocal(&ctor)) return nullptr; - MessagePort* port = nullptr; // Construct a new instance, then assign the listener instance and possibly // the MessagePortData to it. Local<Object> instance; if (!ctor->NewInstance(context).ToLocal(&instance)) return nullptr; - ASSIGN_OR_RETURN_UNWRAP(&port, instance, nullptr); + MessagePort* port = Unwrap<MessagePort>(instance); + CHECK_NOT_NULL(port); if (data) { port->Detach(); port->data_ = std::move(data); |