[njs] Simplified condition in njs_function_alloc().

Valentin Bartenev vbart at nginx.com
Sat May 4 13:58:06 UTC 2019


details:   https://hg.nginx.org/njs/rev/551d173ab9ec
branches:  
changeset: 943:551d173ab9ec
user:      Valentin Bartenev <vbart at nginx.com>
date:      Sat May 04 05:52:15 2019 +0300
description:
Simplified condition in njs_function_alloc().

There's no reason to check both flags when one depends on another.
See just a few lines above: function->ctor = !lambda->arrow.

Now the condition is made similar to the one in njs_method_private_copy().

diffstat:

 njs/njs_function.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (18 lines):

diff -r fe74f3c7863a -r 551d173ab9ec njs/njs_function.c
--- a/njs/njs_function.c	Sat May 04 00:56:39 2019 +0300
+++ b/njs/njs_function.c	Sat May 04 05:52:15 2019 +0300
@@ -42,11 +42,11 @@ njs_function_alloc(njs_vm_t *vm, njs_fun
     function->args_offset = 1;
     function->u.lambda = lambda;
 
-    if (lambda->arrow || !function->ctor) {
-        function->object.shared_hash = vm->shared->arrow_instance_hash;
+    if (function->ctor) {
+        function->object.shared_hash = vm->shared->function_instance_hash;
 
     } else {
-        function->object.shared_hash = vm->shared->function_instance_hash;
+        function->object.shared_hash = vm->shared->arrow_instance_hash;
     }
 
     function->object.__proto__ = &vm->prototypes[NJS_PROTOTYPE_FUNCTION].object;


More information about the nginx-devel mailing list