[njs] Improved parsing object literals.

Dmitry Volyntsev xeioex at nginx.com
Fri Feb 1 15:26:48 UTC 2019


details:   https://hg.nginx.org/njs/rev/476bb5ed52e8
branches:  
changeset: 751:476bb5ed52e8
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Feb 01 18:26:18 2019 +0300
description:
Improved parsing object literals.

diffstat:

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

diffs (31 lines):

diff -r 94fc00372558 -r 476bb5ed52e8 njs/njs_parser.c
--- a/njs/njs_parser.c	Fri Feb 01 18:09:02 2019 +0300
+++ b/njs/njs_parser.c	Fri Feb 01 18:26:18 2019 +0300
@@ -2151,6 +2151,13 @@ njs_parser_object(njs_vm_t *vm, njs_pars
 
     left = NULL;
 
+    object = njs_parser_node_new(vm, parser, NJS_TOKEN_OBJECT_VALUE);
+    if (nxt_slow_path(object == NULL)) {
+        return NJS_TOKEN_ERROR;
+    }
+
+    object->u.object = obj;
+
     for ( ;; ) {
         token = njs_parser_property_token(parser);
 
@@ -2177,13 +2184,6 @@ njs_parser_object(njs_vm_t *vm, njs_pars
             return token;
         }
 
-        object = njs_parser_node_new(vm, parser, NJS_TOKEN_OBJECT_VALUE);
-        if (nxt_slow_path(object == NULL)) {
-            return NJS_TOKEN_ERROR;
-        }
-
-        object->u.object = obj;
-
         propref = njs_parser_node_new(vm, parser, NJS_TOKEN_PROPERTY);
         if (nxt_slow_path(propref == NULL)) {
             return NJS_TOKEN_ERROR;


More information about the nginx-devel mailing list