diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-04-07 16:57:22 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-04-23 17:21:24 +0800 |
commit | ce4c8c823ca03d065fb880c50789ba136722c8e7 (patch) | |
tree | e20b4ad55544b6bbe703d6a4f591ce51bacf692c /src/node_internals.h | |
parent | 8b012e1464a7f90343c58fdbfa7bc0462c90f56a (diff) | |
download | android-node-v8-ce4c8c823ca03d065fb880c50789ba136722c8e7.tar.gz android-node-v8-ce4c8c823ca03d065fb880c50789ba136722c8e7.tar.bz2 android-node-v8-ce4c8c823ca03d065fb880c50789ba136722c8e7.zip |
fs: return stats to JS in sync methods
- Reduce reference to the global `statValues` by returning
the changed stats array from the synchronous methods. Having
a local returned value also makes the future integration
of BigInt easier.
- Also returns the filled array from node::FillGlobalStatsArray
and node::FillStatsArray in the C++ side.
PR-URL: https://github.com/nodejs/node/pull/20167
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'src/node_internals.h')
-rw-r--r-- | src/node_internals.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/node_internals.h b/src/node_internals.h index 492a36296f..50047e3307 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -313,7 +313,7 @@ v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env, const char* deprecation_code); template <typename NativeT, typename V8T> -void FillStatsArray(AliasedBuffer<NativeT, V8T>* fields_ptr, +v8::Local<v8::Value> FillStatsArray(AliasedBuffer<NativeT, V8T>* fields_ptr, const uv_stat_t* s, int offset = 0) { AliasedBuffer<NativeT, V8T>& fields = *fields_ptr; fields[offset + 0] = s->st_dev; @@ -347,12 +347,14 @@ void FillStatsArray(AliasedBuffer<NativeT, V8T>* fields_ptr, X(12, ctim) X(13, birthtim) #undef X + + return fields_ptr->GetJSArray(); } -inline void FillGlobalStatsArray(Environment* env, - const uv_stat_t* s, - int offset = 0) { - node::FillStatsArray(env->fs_stats_field_array(), s, offset); +inline v8::Local<v8::Value> FillGlobalStatsArray(Environment* env, + const uv_stat_t* s, + int offset = 0) { + return node::FillStatsArray(env->fs_stats_field_array(), s, offset); } void SetupProcessObject(Environment* env, |