From: Dmitry Volyntsev Date: Mon, 24 May 2021 10:51:48 +0000 (+0000) Subject: Simplified String.prototype.repeat() to match the spec. X-Git-Tag: 0.6.0~22 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=b0a4358a86a73408530d0ed8717b8d5a3ceeb2fb;p=njs.git Simplified String.prototype.repeat() to match the spec. --- diff --git a/src/njs_string.c b/src/njs_string.c index d8659395..f5cf6b46 100644 --- a/src/njs_string.c +++ b/src/njs_string.c @@ -2924,7 +2924,6 @@ njs_string_prototype_repeat(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, 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, njs_value_t *args, njs_uint_t nargs, 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)) {