Skip to content

Commit 8464667

Browse files
trevnorrisFishrock123
authored andcommittedJan 6, 2016
node: fix erroneously named function call
The initial implementation of setPropByIndex() set the value of an Array by index during development. Though the final form of the function simply pushes passed values to an array as passed by arguments. Thus the functions have been renamed to pushValueToArray() and push_values_to_array_function() respectively. Also add define for maximum number of arguments should be used before hitting the limit of performance increase. Fixes: 494227b "node: improve GetActiveRequests performance" PR-URL: nodejs#3780 Reviewed-By: Fedor Indutny <[email protected]>

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed
 

‎src/env.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ namespace node {
3838
#define NODE_ISOLATE_SLOT 3
3939
#endif
4040

41+
// The number of items passed to push_values_to_array_function has diminishing
42+
// returns around 8. This should be used at all call sites using said function.
43+
#ifndef NODE_PUSH_VAL_TO_ARRAY_MAX
44+
#define NODE_PUSH_VAL_TO_ARRAY_MAX 8
45+
#endif
46+
4147
// Strings are per-isolate primitives but Environment proxies them
4248
// for the sake of convenience. Strings should be ASCII-only.
4349
#define PER_ISOLATE_STRING_PROPERTIES(V) \
@@ -231,12 +237,11 @@ namespace node {
231237
V(zero_return_string, "ZERO_RETURN") \
232238

233239
#define ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) \
234-
V(add_properties_by_index_function, v8::Function) \
235240
V(as_external, v8::External) \
241+
V(async_hooks_destroy_function, v8::Function) \
236242
V(async_hooks_init_function, v8::Function) \
237-
V(async_hooks_pre_function, v8::Function) \
238243
V(async_hooks_post_function, v8::Function) \
239-
V(async_hooks_destroy_function, v8::Function) \
244+
V(async_hooks_pre_function, v8::Function) \
240245
V(binding_cache_object, v8::Object) \
241246
V(buffer_constructor_function, v8::Function) \
242247
V(buffer_prototype_object, v8::Object) \
@@ -250,6 +255,7 @@ namespace node {
250255
V(pipe_constructor_template, v8::FunctionTemplate) \
251256
V(process_object, v8::Object) \
252257
V(promise_reject_function, v8::Function) \
258+
V(push_values_to_array_function, v8::Function) \
253259
V(script_context_constructor_template, v8::FunctionTemplate) \
254260
V(script_data_constructor_function, v8::Function) \
255261
V(secure_context_constructor_template, v8::FunctionTemplate) \

‎src/node.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ void SetupProcessObject(const FunctionCallbackInfo<Value>& args) {
10631063

10641064
CHECK(args[0]->IsFunction());
10651065

1066-
env->set_add_properties_by_index_function(args[0].As<Function>());
1066+
env->set_push_values_to_array_function(args[0].As<Function>());
10671067
env->process_object()->Delete(
10681068
FIXED_ONE_BYTE_STRING(env->isolate(), "_setupProcessObject"));
10691069
}
@@ -1607,7 +1607,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
16071607

16081608
Local<Array> ary = Array::New(args.GetIsolate());
16091609
Local<Context> ctx = env->context();
1610-
Local<Function> fn = env->add_properties_by_index_function();
1610+
Local<Function> fn = env->push_values_to_array_function();
16111611
static const size_t argc = 8;
16121612
Local<Value> argv[argc];
16131613
size_t i = 0;

‎src/node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@
181181
}
182182

183183
startup.setupProcessObject = function() {
184-
process._setupProcessObject(setPropByIndex);
184+
process._setupProcessObject(pushValueToArray);
185185

186-
function setPropByIndex() {
186+
function pushValueToArray() {
187187
for (var i = 0; i < arguments.length; i++)
188188
this.push(arguments[i]);
189189
}

0 commit comments

Comments
 (0)
Please sign in to comment.