summaryrefslogtreecommitdiff
path: root/perly.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-12-03 14:08:56 +0000
committerDavid Mitchell <davem@iabyn.com>2016-12-05 11:54:03 +0000
commit73f2343123f6b98ed4a0b1fc57fd65e720f38b1b (patch)
tree5586dc193878d48325595f6fdd9f1f9422c51ca3 /perly.c
parent0e0707c5741b52ed1f26e1f69d89b66a1b05f985 (diff)
downloadperl-73f2343123f6b98ed4a0b1fc57fd65e720f38b1b.tar.gz
optimising yyparse: avoid a < 0 check
casting to unsigned allows (0 <= yyn <= YYLAST) to be done in a single conditional.
Diffstat (limited to 'perly.c')
-rw-r--r--perly.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/perly.c b/perly.c
index d20e4e3b7d..ac6112af2f 100644
--- a/perly.c
+++ b/perly.c
@@ -355,9 +355,11 @@ Perl_yyparse (pTHX_ int gramtype)
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
+ * detect an error, take that action.
+ * Casting yyn to unsigned allows a >=0 test to be included as
+ * part of the <=YYLAST test for speed */
yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ if ((unsigned int)yyn > YYLAST || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0) {