Welcome! Log In Create A New Profile

Advanced

[njs] Improved Array.prototype.includes().

Dmitry Volyntsev
November 27, 2019 09:16AM
details: https://hg.nginx.org/njs/rev/4b2b845c3bad
branches:
changeset: 1266:4b2b845c3bad
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed Nov 27 16:51:29 2019 +0300
description:
Improved Array.prototype.includes().

diffstat:

src/njs_array.c | 30 ++++--------------------------
1 files changed, 4 insertions(+), 26 deletions(-)

diffs (47 lines):

diff -r ba1499515923 -r 4b2b845c3bad src/njs_array.c
--- a/src/njs_array.c Wed Nov 27 15:48:32 2019 +0300
+++ b/src/njs_array.c Wed Nov 27 16:51:29 2019 +0300
@@ -1886,21 +1886,7 @@ njs_array_handler_includes(njs_vm_t *vm,
entry = njs_value_arg(&njs_value_undefined);
}

- if (njs_values_strict_equal(args->argument, entry)) {
- njs_set_true(&vm->retval);
-
- return 1;
- }
-
- return NJS_OK;
-}
-
-
-static njs_int_t
-njs_array_handler_includes_nan(njs_vm_t *vm, njs_array_iterator_args_t *args,
- njs_value_t *entry, uint32_t n)
-{
- if (njs_is_numeric(entry) && isnan(njs_number(entry))) {
+ if (njs_values_same_zero(args->argument, entry)) {
njs_set_true(&vm->retval);

return 1;
@@ -1953,17 +1939,9 @@ njs_array_prototype_includes(njs_vm_t *v
iargs.from = (uint32_t) from;
iargs.to = length;

- if (njs_is_number(iargs.argument) && isnan(njs_number(iargs.argument))) {
- ret = njs_array_iterator(vm, &iargs, njs_array_handler_includes_nan);
- if (njs_fast_path(ret == NJS_DECLINED)) {
- return NJS_OK;
- }
-
- } else {
- ret = njs_array_iterator(vm, &iargs, njs_array_handler_includes);
- if (njs_fast_path(ret == NJS_DECLINED)) {
- return NJS_OK;
- }
+ ret = njs_array_iterator(vm, &iargs, njs_array_handler_includes);
+ if (njs_fast_path(ret == NJS_DECLINED)) {
+ return NJS_OK;
}

not_found:
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Improved Array.prototype.includes().

Dmitry Volyntsev 62 November 27, 2019 09:16AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready