From 0a8db2289d10e26b46047c6b01a124974f566bb2 Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Mon, 1 Jun 2009 01:28:18 +0200 Subject: [PATCH] Remove redundant null-check in member functions of structs that don't have an invariant. --- dmd/func.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dmd/func.c b/dmd/func.c index c60265a3..e4031ed7 100644 --- a/dmd/func.c +++ b/dmd/func.c @@ -1266,12 +1266,17 @@ void FuncDeclaration::semantic3(Scope *sc) } else { // Call invariant virtually - ThisExp *v = new ThisExp(0); - v->type = vthis->type; - e = new AssertExp(loc, v, NULL); + // LDC: unless this is a struct without invariant + StructDeclaration* sd = ad->isStructDeclaration(); + if (!sd || sd->inv) + { + ThisExp *v = new ThisExp(0); + v->type = vthis->type; + e = new AssertExp(loc, v, NULL); + } // LDC: check for null this - v = new ThisExp(0); + ThisExp* v = new ThisExp(0); v->type = vthis->type; v->var = vthis;