[njs] Using njs_is_defined() where appropriate.

Dmitry Volyntsev xeioex at nginx.com
Mon Aug 5 15:18:07 UTC 2019


details:   https://hg.nginx.org/njs/rev/8eb80902c862
branches:  
changeset: 1104:8eb80902c862
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon Aug 05 18:17:15 2019 +0300
description:
Using njs_is_defined() where appropriate.

diffstat:

 src/njs_array.c       |  4 ++--
 src/njs_json.c        |  2 +-
 src/njs_object_prop.c |  4 ++--
 src/njs_regexp.c      |  2 +-
 src/njs_string.c      |  4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diffs (73 lines):

diff -r 88ff9dfa847e -r 8eb80902c862 src/njs_array.c
--- a/src/njs_array.c	Sun Aug 04 03:59:42 2019 -0400
+++ b/src/njs_array.c	Mon Aug 05 18:17:15 2019 +0300
@@ -434,8 +434,8 @@ njs_array_prototype_slice(njs_vm_t *vm, 
         length = 0;
 
     } else {
-        if (!njs_is_undefined(njs_arg(args, nargs, 2))) {
-            end = njs_primitive_value_to_integer(&args[2]);
+        if (njs_is_defined(njs_arg(args, nargs, 2))) {
+            end = njs_primitive_value_to_integer(njs_argument(args, 2));
 
         } else {
             end = length;
diff -r 88ff9dfa847e -r 8eb80902c862 src/njs_json.c
--- a/src/njs_json.c	Sun Aug 04 03:59:42 2019 -0400
+++ b/src/njs_json.c	Mon Aug 05 18:17:15 2019 +0300
@@ -1408,7 +1408,7 @@ start:
             break;
 
         case NJS_JSON_ARRAY_TO_JSON_REPLACED:
-            if (!njs_is_undefined(&stringify->retval)
+            if (njs_is_defined(&stringify->retval)
                 && njs_is_function(&stringify->replacer))
             {
                 ret = njs_json_stringify_replacer(vm, stringify, NULL,
diff -r 88ff9dfa847e -r 8eb80902c862 src/njs_object_prop.c
--- a/src/njs_object_prop.c	Sun Aug 04 03:59:42 2019 -0400
+++ b/src/njs_object_prop.c	Mon Aug 05 18:17:15 2019 +0300
@@ -348,7 +348,7 @@ njs_descriptor_prop(njs_vm_t *vm, const 
 
     pr = njs_object_property(vm, desc, &pq);
     if (pr != NULL) {
-        if (!njs_is_undefined(&pr->value) && !njs_is_function(&pr->value)) {
+        if (njs_is_defined(&pr->value) && !njs_is_function(&pr->value)) {
             njs_type_error(vm, "Getter must be a function");
             return NULL;
         }
@@ -365,7 +365,7 @@ njs_descriptor_prop(njs_vm_t *vm, const 
 
     pr = njs_object_property(vm, desc, &pq);
     if (pr != NULL) {
-        if (!njs_is_undefined(&pr->value) && !njs_is_function(&pr->value)) {
+        if (njs_is_defined(&pr->value) && !njs_is_function(&pr->value)) {
             njs_type_error(vm, "Setter must be a function");
             return NULL;
         }
diff -r 88ff9dfa847e -r 8eb80902c862 src/njs_regexp.c
--- a/src/njs_regexp.c	Sun Aug 04 03:59:42 2019 -0400
+++ b/src/njs_regexp.c	Mon Aug 05 18:17:15 2019 +0300
@@ -148,7 +148,7 @@ njs_regexp_constructor(njs_vm_t *vm, njs
         pattern = &source;
     }
 
-    if (!njs_is_undefined(flags)) {
+    if (njs_is_defined(flags)) {
         ret = njs_primitive_value_to_string(vm, &flags_string, flags);
         if (njs_slow_path(ret != NJS_OK)) {
             return ret;
diff -r 88ff9dfa847e -r 8eb80902c862 src/njs_string.c
--- a/src/njs_string.c	Sun Aug 04 03:59:42 2019 -0400
+++ b/src/njs_string.c	Mon Aug 05 18:17:15 2019 +0300
@@ -1290,8 +1290,8 @@ njs_string_slice_args(njs_slice_prop_t *
         length = 0;
 
     } else {
-        if (!njs_is_undefined(njs_arg(args, nargs, 2))) {
-            value = njs_arg(args, nargs, 2);
+        if (njs_is_defined(njs_arg(args, nargs, 2))) {
+            value = njs_argument(args, 2);
             end = njs_number(value);
 
         } else {


More information about the nginx-devel mailing list