]> git.kaiwu.me - njs.git/commitdiff
Simplified condition in njs_function_alloc().
authorValentin Bartenev <vbart@nginx.com>
Sat, 4 May 2019 02:52:15 +0000 (05:52 +0300)
committerValentin Bartenev <vbart@nginx.com>
Sat, 4 May 2019 02:52:15 +0000 (05:52 +0300)
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().

njs/njs_function.c

index f1743cd24137b4b6ce190d97bc848ef9c3e10968..9d669bcc5d2cce4430d4858b52bf578b8311998a 100644 (file)
@@ -42,11 +42,11 @@ njs_function_alloc(njs_vm_t *vm, njs_function_lambda_t *lambda,
     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;