oh well, shove it; inline some things, the most legible ones

mostly for benefit of not-the-latest-llvm-or-gcc compilers
This commit is contained in:
tg 2011-12-02 23:05:18 +00:00
parent 1ac636670f
commit 73688b3b3c
1 changed files with 18 additions and 20 deletions

38
funcs.c
View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.201 2011/12/02 22:55:48 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.202 2011/12/02 23:05:18 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -2752,6 +2752,7 @@ c_test(const char **wp)
* Attempt to conform to POSIX special cases. This is pretty * Attempt to conform to POSIX special cases. This is pretty
* dumb code straight-forward from the 2008 spec, but unless * dumb code straight-forward from the 2008 spec, but unless
* the old pdksh code doesn't live from so many assumptions. * the old pdksh code doesn't live from so many assumptions.
* It does, though, inline some calls to '(*te.funcname)()'.
*/ */
switch (argc - 1) { switch (argc - 1) {
case 0: case 0:
@ -2762,14 +2763,13 @@ c_test(const char **wp)
goto ptest_unary; goto ptest_unary;
case 2: case 2:
ptest_two: ptest_two:
if ((*te.isa)(&te, TM_NOT)) { if (ptest_isa(&te, TM_NOT)) {
++invert; ++invert;
goto ptest_one; goto ptest_one;
} }
if ((op = (*te.isa)(&te, TM_UNOP))) { if ((op = ptest_isa(&te, TM_UNOP))) {
ptest_unary: ptest_unary:
rv = (*te.eval)(&te, op, rv = test_eval(&te, op, *te.pos.wp++, NULL, true);
(*te.getopnd)(&te, op, true), NULL, true);
ptest_out: ptest_out:
return ((invert & 1) ? rv : !rv); return ((invert & 1) ? rv : !rv);
} }
@ -2778,27 +2778,25 @@ c_test(const char **wp)
case 3: case 3:
ptest_three: ptest_three:
swp = te.pos.wp; swp = te.pos.wp;
/* inside knowledge shows ptest_getopnd never evaluates */ /* use inside knowledge of ptest_getopnd inlined below */
/* skip lhs, without evaluation; assign with */ lhs = *te.pos.wp++;
lhs = (*te.getopnd)(&te, TO_NONOP, true); if ((op = ptest_isa(&te, TM_BINOP))) {
if ((op = (*te.isa)(&te, TM_BINOP))) {
/* test lhs op rhs */ /* test lhs op rhs */
rv = (*te.eval)(&te, op, lhs, rv = test_eval(&te, op, lhs, *te.pos.wp++, true);
(*te.getopnd)(&te, op, true), true);
goto ptest_out; goto ptest_out;
} }
/* back up to lhs */ /* back up to lhs */
te.pos.wp = swp; te.pos.wp = swp;
if ((*te.isa)(&te, TM_NOT)) { if (ptest_isa(&te, TM_NOT)) {
++invert; ++invert;
goto ptest_two; goto ptest_two;
} }
if ((*te.isa)(&te, TM_OPAREN)) { if (ptest_isa(&te, TM_OPAREN)) {
swp = te.pos.wp; swp = te.pos.wp;
/* skip operand, without evaluation */ /* skip operand, without evaluation */
(*te.getopnd)(&te, TO_NONOP, false); te.pos.wp++;
/* check for closing parenthesis */ /* check for closing parenthesis */
op = (*te.isa)(&te, TM_CPAREN); op = ptest_isa(&te, TM_CPAREN);
/* back up to operand */ /* back up to operand */
te.pos.wp = swp; te.pos.wp = swp;
/* if there was a closing paren, handle it */ /* if there was a closing paren, handle it */
@ -2809,17 +2807,17 @@ c_test(const char **wp)
/* let the parser deal with it */ /* let the parser deal with it */
break; break;
case 4: case 4:
if ((*te.isa)(&te, TM_NOT)) { if (ptest_isa(&te, TM_NOT)) {
++invert; ++invert;
goto ptest_three; goto ptest_three;
} }
if ((*te.isa)(&te, TM_OPAREN)) { if (ptest_isa(&te, TM_OPAREN)) {
swp = te.pos.wp; swp = te.pos.wp;
/* skip two operands, without evaluation */ /* skip two operands, without evaluation */
(*te.getopnd)(&te, TO_NONOP, false); te.pos.wp++;
(*te.getopnd)(&te, TO_NONOP, false); te.pos.wp++;
/* check for closing parenthesis */ /* check for closing parenthesis */
op = (*te.isa)(&te, TM_CPAREN); op = ptest_isa(&te, TM_CPAREN);
/* back up to first operand */ /* back up to first operand */
te.pos.wp = swp; te.pos.wp = swp;
/* if there was a closing paren, handle it */ /* if there was a closing paren, handle it */