Skip to content

Commit

Permalink
Replace AliasDeclaration::inSemantic with Declaration::inuse
Browse files Browse the repository at this point in the history
I noticed that it was completely redundant. We can reduce memory size a little.
  • Loading branch information
9rnsr committed Jun 10, 2015
1 parent 4e5a31e commit 525dcb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
27 changes: 12 additions & 15 deletions src/declaration.c
Expand Up @@ -280,7 +280,6 @@ bool TupleDeclaration::needThis()
return false;
}


/********************************* AliasDeclaration ****************************/

AliasDeclaration::AliasDeclaration(Loc loc, Identifier *id, Type *type)
Expand All @@ -293,7 +292,6 @@ AliasDeclaration::AliasDeclaration(Loc loc, Identifier *id, Type *type)
this->aliassym = NULL;
this->import = NULL;
this->overnext = NULL;
this->inSemantic = 0;
assert(type);
}

Expand All @@ -307,7 +305,6 @@ AliasDeclaration::AliasDeclaration(Loc loc, Identifier *id, Dsymbol *s)
this->aliassym = s;
this->import = NULL;
this->overnext = NULL;
this->inSemantic = 0;
assert(s);
}

Expand All @@ -331,7 +328,7 @@ void AliasDeclaration::semantic(Scope *sc)
aliassym->semantic(sc);
return;
}
this->inSemantic = 1;
inuse = 1;

storage_class |= sc->stc & STCdeprecated;
protection = sc->protection;
Expand Down Expand Up @@ -411,7 +408,7 @@ void AliasDeclaration::semantic(Scope *sc)
}
if (overnext)
ScopeDsymbol::multiplyDefined(Loc(), overnext, this);
this->inSemantic = 0;
inuse = 0;

if (global.gag && errors != global.errors)
type = savedtype;
Expand Down Expand Up @@ -492,7 +489,7 @@ void AliasDeclaration::semantic(Scope *sc)
}
//printf("setting aliassym %s to %s %s\n", toChars(), s->kind(), s->toChars());
aliassym = s;
this->inSemantic = 0;
inuse = 0;
}

bool AliasDeclaration::overloadInsert(Dsymbol *s)
Expand Down Expand Up @@ -548,13 +545,13 @@ Type *AliasDeclaration::getType()

Dsymbol *AliasDeclaration::toAlias()
{
//printf("[%s] AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s', inSemantic = %d)\n",
// loc.toChars(), toChars(), this, aliassym, aliassym ? aliassym->kind() : "", inSemantic);
//printf("[%s] AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s', inuse = %d)\n",
// loc.toChars(), toChars(), this, aliassym, aliassym ? aliassym->kind() : "", inuse);
assert(this != aliassym);
//static int count; if (++count == 10) *(char*)0=0;
if (inSemantic == 1 && type && scope)
if (inuse == 1 && type && scope)
{
inSemantic = 2;
inuse = 2;
unsigned olderrors = global.errors;
Dsymbol *s = type->toDsymbol(scope);
//printf("[%s] type = %s, s = %p, this = %p\n", loc.toChars(), type->toChars(), s, this);
Expand All @@ -566,7 +563,7 @@ Dsymbol *AliasDeclaration::toAlias()
if (global.errors != olderrors)
goto Lerr;
aliassym = s;
inSemantic = 0;
inuse = 0;
}
else
{
Expand All @@ -576,10 +573,10 @@ Dsymbol *AliasDeclaration::toAlias()
if (global.errors != olderrors)
goto Lerr;
//printf("t = %s\n", t->toChars());
inSemantic = 0;
inuse = 0;
}
}
if (inSemantic)
if (inuse)
{
error("recursive alias declaration");

Expand All @@ -604,9 +601,9 @@ Dsymbol *AliasDeclaration::toAlias()
}
else if (scope)
semantic(scope);
inSemantic = 1;
inuse = 1;
Dsymbol *s = aliassym ? aliassym->toAlias() : this;
inSemantic = 0;
inuse = 0;
return s;
}

Expand Down
1 change: 0 additions & 1 deletion src/declaration.h
Expand Up @@ -195,7 +195,6 @@ class AliasDeclaration : public Declaration
Dsymbol *aliassym;
Dsymbol *overnext; // next in overload list
Dsymbol *import; // !=NULL if unresolved internal alias for selective import
int inSemantic;

AliasDeclaration(Loc loc, Identifier *ident, Type *type);
AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s);
Expand Down

0 comments on commit 525dcb6

Please sign in to comment.