diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-21 08:34:00 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-10-24 09:57:42 +0200 |
commit | 1365f657b51d31044cca54c3152d3940a4bd9dc3 (patch) | |
tree | 4772c2b484555de0a0368b35ebf889ff23d154c2 /src/stream_base.h | |
parent | bb79e768e5ab150f2075780734005783d53eb3ca (diff) | |
download | node-new-1365f657b51d31044cca54c3152d3940a4bd9dc3.tar.gz |
src: improve StreamBase read throughput
Improve performance by providing JS with the raw ingridients
for the read data, i.e. an `ArrayBuffer` + offset + length
fields, instead of creating `Buffer` instances in C++ land.
PR-URL: https://github.com/nodejs/node/pull/23797
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/stream_base.h')
-rw-r--r-- | src/stream_base.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/stream_base.h b/src/stream_base.h index d8e6df960f..039009e072 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -264,7 +264,9 @@ class StreamBase : public StreamResource { virtual bool IsIPCPipe(); virtual int GetFD(); - void CallJSOnreadMethod(ssize_t nread, v8::Local<v8::Object> buf); + void CallJSOnreadMethod(ssize_t nread, + v8::Local<v8::ArrayBuffer> ab, + size_t offset = 0); // This is named `stream_env` to avoid name clashes, because a lot of // subclasses are also `BaseObject`s. @@ -326,12 +328,20 @@ class StreamBase : public StreamResource { const v8::FunctionCallbackInfo<v8::Value>& args)> static void JSMethod(const v8::FunctionCallbackInfo<v8::Value>& args); + // Internal, used only in StreamBase methods + env.cc. + enum StreamBaseStateFields { + kReadBytesOrError, + kArrayBufferOffset, + kNumStreamBaseStateFields + }; + private: Environment* env_; EmitToJSStreamListener default_listener_; friend class WriteWrap; friend class ShutdownWrap; + friend class Environment; // For kNumStreamBaseStateFields. }; |