diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-07-16 23:31:28 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-07-19 13:11:42 +0300 |
commit | 2d32a7e90a510044330d55c599ad6c59e92779f5 (patch) | |
tree | 51049bc65d3559f94ce469dd181b27ea20ff87be /src/node_file.h | |
parent | 5e5ffc81fa823221777ab7c9fed33093afdfa876 (diff) |
src: use offset calc. instead of `req->data` in node_file
A small refactor – this removes one layer of pointer indirection.
(The performance gain is likely negligible, the main point here
being that this encapsulates libuv request management a bit more.)
PR-URL: https://github.com/nodejs/node/pull/21839
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Diffstat (limited to 'src/node_file.h')
-rw-r--r-- | src/node_file.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/node_file.h b/src/node_file.h index 6b45dc88175..141d1d42d74 100644 --- a/src/node_file.h +++ b/src/node_file.h @@ -68,6 +68,10 @@ class FSReqBase : public ReqWrap<uv_fs_t> { bool use_bigint() const { return use_bigint_; } + static FSReqBase* from_req(uv_fs_t* req) { + return static_cast<FSReqBase*>(ReqWrap::from_req(req)); + } + private: enum encoding encoding_ = UTF8; bool has_data_ = false; @@ -284,6 +288,10 @@ class FileHandle : public AsyncWrap, public StreamBase { void Reject(Local<Value> reason); + static CloseReq* from_req(uv_fs_t* req) { + return static_cast<CloseReq*>(ReqWrap::from_req(req)); + } + private: Persistent<Promise> promise_; Persistent<Value> ref_; |