Welcome! Log In Create A New Profile

Advanced

[njs] Simplified String.prototype.repeat() to match the spec.

Dmitry Volyntsev
May 24, 2021 06:54AM
details: https://hg.nginx.org/njs/rev/f1e8e753417d
branches:
changeset: 1639:f1e8e753417d
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Mon May 24 10:51:48 2021 +0000
description:
Simplified String.prototype.repeat() to match the spec.

diffstat:

src/njs_string.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)

diffs (32 lines):

diff -r 87f91ff16931 -r f1e8e753417d src/njs_string.c
--- a/src/njs_string.c Mon May 24 10:51:47 2021 +0000
+++ b/src/njs_string.c Mon May 24 10:51:48 2021 +0000
@@ -2924,7 +2924,6 @@ njs_string_prototype_repeat(njs_vm_t *vm
njs_index_t unused)
{
u_char *p;
- double count;
int64_t n, max;
uint64_t size, length;
njs_int_t ret;
@@ -2944,18 +2943,16 @@ njs_string_prototype_repeat(njs_vm_t *vm
return ret;
}

- ret = njs_value_to_number(vm, njs_arg(args, nargs, 1), &count);
+ ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &n);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}

- if (njs_slow_path(!isnan(count) && (count < 0 || isinf(count)))) {
+ if (njs_slow_path(n < 0 || n == INT64_MAX)) {
njs_range_error(vm, NULL);
return NJS_ERROR;
}

- n = njs_number_to_integer(count);
-
(void) njs_string_prop(&string, this);

if (njs_slow_path(n == 0 || string.size == 0)) {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Simplified String.prototype.repeat() to match the spec.

Dmitry Volyntsev 95 May 24, 2021 06:54AM



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

Online Users

Guests: 63
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