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/js_stream.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/js_stream.cc')
-rw-r--r-- | src/js_stream.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/js_stream.cc b/src/js_stream.cc index 1d61605d645..2663106ba7a 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -167,9 +167,9 @@ void JSStream::ReadBuffer(const FunctionCallbackInfo<Value>& args) { JSStream* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); - CHECK(Buffer::HasInstance(args[0])); - char* data = Buffer::Data(args[0]); - int len = Buffer::Length(args[0]); + ArrayBufferViewContents<char> buffer(args[0]); + const char* data = buffer.data(); + int len = buffer.length(); // Repeatedly ask the stream's owner for memory, copy the data that we // just read from JS into those buffers and emit them as reads. |