Welcome! Log In Create A New Profile

Advanced

[njs] Small optimizations.

April 03, 2018 10:58AM
details: http://hg.nginx.org/njs/rev/addefc71957b
branches:
changeset: 488:addefc71957b
user: Igor Sysoev <igor@sysoev.ru>
date: Tue Apr 03 17:55:08 2018 +0300
description:
Small optimizations.

diffstat:

njs/njs_parser_expression.c | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)

diffs (63 lines):

diff -r 671d9dd1ffeb -r addefc71957b njs/njs_parser_expression.c
--- a/njs/njs_parser_expression.c Tue Apr 03 17:55:04 2018 +0300
+++ b/njs/njs_parser_expression.c Tue Apr 03 17:55:08 2018 +0300
@@ -762,19 +762,16 @@ njs_parser_unary_expression(njs_vm_t *vm
return NJS_TOKEN_ILLEGAL;
}

- if (token == NJS_TOKEN_UNARY_PLUS
- && parser->node->token == NJS_TOKEN_NUMBER)
- {
+ node = parser->node;
+
+ if (token == NJS_TOKEN_UNARY_PLUS && node->token == NJS_TOKEN_NUMBER) {
/* Skip the unary plus of number. */
return next;
}

- if (token == NJS_TOKEN_UNARY_NEGATION
- && parser->node->token == NJS_TOKEN_NUMBER)
- {
+ if (token == NJS_TOKEN_UNARY_NEGATION && node->token == NJS_TOKEN_NUMBER) {
+
/* Optimization of common negative number. */
-
- node = parser->node;
num = -node->u.value.data.u.number;
node->u.value.data.u.number = num;
node->u.value.data.truth = njs_is_number_true(num);
@@ -784,11 +781,11 @@ njs_parser_unary_expression(njs_vm_t *vm

if (token == NJS_TOKEN_DELETE) {

- switch (parser->node->token) {
+ switch (node->token) {

case NJS_TOKEN_PROPERTY:
- parser->node->token = NJS_TOKEN_PROPERTY_DELETE;
- parser->node->u.operation = njs_vmcode_property_delete;
+ node->token = NJS_TOKEN_PROPERTY_DELETE;
+ node->u.operation = njs_vmcode_property_delete;
parser->code_size += sizeof(njs_vmcode_3addr_t);

return next;
@@ -805,8 +802,8 @@ njs_parser_unary_expression(njs_vm_t *vm
}
}

- if (token == NJS_TOKEN_TYPEOF && parser->node->token == NJS_TOKEN_NAME) {
- parser->node->reference = NJS_TYPEOF;
+ if (token == NJS_TOKEN_TYPEOF && node->token == NJS_TOKEN_NAME) {
+ node->reference = NJS_TYPEOF;
}

node = njs_parser_node_alloc(vm);
@@ -876,7 +873,7 @@ njs_parser_inc_dec_expression(njs_vm_t *
node->left = parser->node;
parser->node = node;

- parser->code_size += (parser->node->token == NJS_TOKEN_NAME) ?
+ parser->code_size += (node->token == NJS_TOKEN_NAME) ?
sizeof(njs_vmcode_3addr_t):
sizeof(njs_vmcode_prop_get_t)
+ sizeof(njs_vmcode_3addr_t)
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Small optimizations.

Igor Sysoev 648 April 03, 2018 10:58AM



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

Online Users

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