Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): reduce code size in CondParser_Eval



details:   https://anonhg.NetBSD.org/src/rev/d42299eaefd5
branches:  trunk
changeset: 938560:d42299eaefd5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 11 05:03:20 2020 +0000

description:
make(1): reduce code size in CondParser_Eval

diffstat:

 usr.bin/make/cond.c |  31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)

diffs (60 lines):

diff -r 8803a39d910c -r d42299eaefd5 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Sep 11 04:57:15 2020 +0000
+++ b/usr.bin/make/cond.c       Fri Sep 11 05:03:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.125 2020/09/11 04:57:15 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.126 2020/09/11 05:03:20 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.125 2020/09/11 04:57:15 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.126 2020/09/11 05:03:20 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.125 2020/09/11 04:57:15 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.126 2020/09/11 05:03:20 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -985,26 +985,15 @@
 static CondEvalResult
 CondParser_Eval(CondParser *par, Boolean *value)
 {
+    Token res = CondParser_Expr(par, TRUE);
+    if (res != TOK_FALSE && res != TOK_TRUE)
+        return COND_INVALID;
 
-    switch (CondParser_Expr(par, TRUE)) {
-    case TOK_TRUE:
-       if (CondParser_Token(par, TRUE) == TOK_EOF) {
-           *value = TRUE;
-           return COND_PARSE;
-       }
-       break;
-    case TOK_FALSE:
-       if (CondParser_Token(par, TRUE) == TOK_EOF) {
-           *value = FALSE;
-           return COND_PARSE;
-       }
-       break;
-    default:
-    case TOK_ERROR:
-       break;
-    }
+    if (CondParser_Token(par, TRUE /* XXX: Why TRUE? */) != TOK_EOF)
+        return COND_INVALID;
 
-    return COND_INVALID;
+    *value = res == TOK_TRUE;
+    return COND_PARSE;
 }
 
 /* Evaluate the condition in the passed line, including any side effects from



Home | Main Index | Thread Index | Old Index