diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-05-26 23:34:51 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-05-29 20:28:38 +0300 |
commit | 5026db142ab5d07c7144dfb272512d3388476a77 (patch) | |
tree | bfe8ca1908b0b94aae498b33ecd3174c7033b2f4 /src/node_serdes.cc | |
parent | 7329c8fe52eb36a238dfdcdd83b8f81034d983fa (diff) |
src: use ArrayBufferViewContents more frequently
Using `ArrayBufferViewContents` over
`Buffer::Data()`/`Buffer::Length()` or `SPREAD_BUFFER_ARG` has the
advantages of creating fewer individual variables to keep track off,
not being a “magic” macro that creates variables, reducing code size,
and being faster when receiving on-heap TypedArrays.
PR-URL: https://github.com/nodejs/node/pull/27920
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_serdes.cc')
-rw-r--r-- | src/node_serdes.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/node_serdes.cc b/src/node_serdes.cc index 41ee8afd8cb..a2d185c4167 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -274,8 +274,8 @@ void SerializerContext::WriteRawBytes(const FunctionCallbackInfo<Value>& args) { ctx->env(), "source must be a TypedArray or a DataView"); } - ctx->serializer_.WriteRawBytes(Buffer::Data(args[0]), - Buffer::Length(args[0])); + ArrayBufferViewContents<char> bytes(args[0]); + ctx->serializer_.WriteRawBytes(bytes.data(), bytes.length()); } DeserializerContext::DeserializerContext(Environment* env, |