[njs] Improved njs_generate_typeof_operation().

Dmitry Volyntsev xeioex at nginx.com
Sat Dec 29 07:33:10 UTC 2018


details:   https://hg.nginx.org/njs/rev/792dbba9b902
branches:  
changeset: 707:792dbba9b902
user:      hongzhidao <hongzhidao at gmail.com>
date:      Sat Dec 29 01:43:44 2018 +0800
description:
Improved njs_generate_typeof_operation().

njs_variable_typeof() cannot fail.

diffstat:

 njs/njs_generator.c |  8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diffs (24 lines):

diff -r c4ec36309dda -r 792dbba9b902 njs/njs_generator.c
--- a/njs/njs_generator.c	Fri Dec 28 19:36:24 2018 +0300
+++ b/njs/njs_generator.c	Sat Dec 29 01:43:44 2018 +0800
@@ -2103,19 +2103,13 @@ njs_generate_typeof_operation(njs_vm_t *
     njs_parser_node_t *node)
 {
     nxt_int_t           ret;
-    njs_index_t         index;
     njs_parser_node_t   *expr;
     njs_vmcode_2addr_t  *code;
 
     expr = node->left;
 
     if (expr->token == NJS_TOKEN_NAME) {
-        index = njs_variable_typeof(vm, expr);
-        if (nxt_slow_path(index == NJS_INDEX_ERROR)) {
-            return NXT_ERROR;
-        }
-
-        expr->index = index;
+        expr->index = njs_variable_typeof(vm, expr);
 
     } else {
         ret = njs_generator(vm, generator, node->left);


More information about the nginx-devel mailing list