[njs] Slight improvements to njs_vmcode_interpreter().
Valentin Bartenev
vbart at nginx.com
Sun Jul 28 12:56:49 UTC 2019
details: https://hg.nginx.org/njs/rev/07989e97b198
branches:
changeset: 1080:07989e97b198
user: Valentin Bartenev <vbart at nginx.com>
date: Sun Jul 28 15:00:40 2019 +0300
description:
Slight improvements to njs_vmcode_interpreter().
No functional changes.
diffstat:
njs/njs_vmcode.c | 26 +++++++++-----------------
1 files changed, 9 insertions(+), 17 deletions(-)
diffs (74 lines):
diff -r 258b1e34ca0f -r 07989e97b198 njs/njs_vmcode.c
--- a/njs/njs_vmcode.c Sun Jul 28 13:19:03 2019 +0300
+++ b/njs/njs_vmcode.c Sun Jul 28 15:00:40 2019 +0300
@@ -379,13 +379,7 @@ next:
|| (!isnan(exponent)
&& !isinf(exponent)));
- if (valid) {
- num = pow(num, exponent);
-
- } else {
- num = NAN;
- }
-
+ num = valid ? pow(num, exponent) : NAN;
break;
case NJS_VMCODE_DIVISION:
@@ -399,19 +393,19 @@ next:
case NJS_VMCODE_BITWISE_AND:
case NJS_VMCODE_BITWISE_OR:
case NJS_VMCODE_BITWISE_XOR:
- i32 = njs_number_to_int32(num);
+ i32 = njs_number_to_int32(njs_number(value2));
switch (op) {
case NJS_VMCODE_BITWISE_AND:
- i32 = i32 & njs_number_to_int32(njs_number(value2));
+ i32 &= njs_number_to_int32(num);
break;
case NJS_VMCODE_BITWISE_OR:
- i32 = i32 | njs_number_to_int32(njs_number(value2));
+ i32 |= njs_number_to_int32(num);
break;
case NJS_VMCODE_BITWISE_XOR:
- i32 = i32 ^ njs_number_to_int32(njs_number(value2));
+ i32 ^= njs_number_to_int32(num);
break;
}
@@ -419,7 +413,7 @@ next:
goto next;
default:
- u32 = njs_number_to_uint32(njs_number(value2));
+ u32 = njs_number_to_uint32(njs_number(value2)) & 0x1f;
switch (op) {
case NJS_VMCODE_LEFT_SHIFT:
@@ -427,19 +421,17 @@ next:
i32 = njs_number_to_int32(num);
if (op == NJS_VMCODE_LEFT_SHIFT) {
- i32 <<= u32 & 0x1f;
+ i32 <<= u32;
} else {
- i32 >>= u32 & 0x1f;
+ i32 >>= u32;
}
njs_set_int32(retval, i32);
-
break;
default: /* NJS_VMCODE_UNSIGNED_RIGHT_SHIFT */
njs_set_uint32(retval,
- njs_number_to_uint32(num)
- >> (u32 & 0x1f));
+ njs_number_to_uint32(num) >> u32);
}
goto next;
More information about the nginx-devel
mailing list