# [hackers] [scc] simplify calls to decay() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 14 Aug 2015 17:08:59 +0200 (CEST)

commit befd4b3ef6de5f64ba923e2b0b86e46609e7e1fd
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Aug 14 16:48:21 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Aug 14 16:48:21 2015 +0200

simplify calls to decay()

It was common check the type of the node before calling
decay(), so it is a good idea put this test inside of
decay() itself. The call to decay() in negation()
was not needed anymore because exp2cond() calls to decay().

diff --git a/cc1/expr.c b/cc1/expr.c
index a85dc91..7eebc53 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -272,8 +272,14 @@ decay(Node *np)
{
Type *tp = np->type;

- if (tp->op == ARY)
+ switch (tp->op) {
+ case ARY:
tp = tp->type;
+ case FTN:
+ break;
+ default:
+ return np;
+ }

return node(OADDR, mktype(tp, PTR, 0, NULL), np, NULL);
}
_AT_@ -286,11 +292,7 @@ eval(Node *np)
if (!np)
return NULL;

- switch (BTYPE(np)) {
- case ARY:
- case FTN:
- np = decay(np);
- }
+ np = decay(np);
if (!isnodecmp(np->op))
return np;
p = node(OCOLON, inttype, constnode(one), constnode(zero));
_AT_@ -562,11 +564,7 @@ negate(Node *np)
static Node *
exp2cond(Node *np, char neg)
{
- switch (BTYPE(np)) {
- case ARY:
- case FTN:
- np = decay(np);
- }
+ np = decay(np);
if (isnodecmp(np->op))
return (neg) ? negate(np) : np;
return compare(ONE ^ neg, np, constnode(zero));
_AT_@ -695,7 +693,6 @@ negation(char op, Node *np)
switch (BTYPE(np)) {
case FTN:
case ARY:
- np = decay(np);
case INT:
case FLOAT:
case PTR:
Received on Fri Aug 14 2015 - 17:08:59 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 14 2015 - 17:12:28 CEST