[njs] Simplified String.prototype.repeat() to match the spec.
Dmitry Volyntsev
xeioex at nginx.com
Mon May 24 10:52:22 UTC 2021
details: https://hg.nginx.org/njs/rev/f1e8e753417d
branches:
changeset: 1639:f1e8e753417d
user: Dmitry Volyntsev <xeioex at 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)) {
More information about the nginx-devel
mailing list