diff options
author | David Mitchell <davem@iabyn.com> | 2016-12-03 14:08:56 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-12-05 11:54:03 +0000 |
commit | 73f2343123f6b98ed4a0b1fc57fd65e720f38b1b (patch) | |
tree | 5586dc193878d48325595f6fdd9f1f9422c51ca3 /perly.c | |
parent | 0e0707c5741b52ed1f26e1f69d89b66a1b05f985 (diff) | |
download | perl-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.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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) { |