mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 09:00:33 +03:00
nested: Use early exit instead of giant if in DtoCreateNestedContextType [nfc]
This commit is contained in:
parent
03429eb60f
commit
0c7660a98b
1 changed files with 95 additions and 92 deletions
|
@ -328,6 +328,7 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
|
|||
IrFunction &irFunc = *getIrFunc(fd);
|
||||
|
||||
if (irFunc.nestedContextCreated) {
|
||||
Logger::println("already done");
|
||||
return;
|
||||
}
|
||||
irFunc.nestedContextCreated = true;
|
||||
|
@ -338,9 +339,22 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
|
|||
DtoCreateNestedContextType(parentFunc);
|
||||
}
|
||||
|
||||
// construct nested variables array
|
||||
if (fd->closureVars.dim > 0) {
|
||||
if (fd->closureVars.dim == 0) {
|
||||
// No local variables of this function are captured.
|
||||
if (parentFunc) {
|
||||
// Propagate context arg properties if the context arg is passed on
|
||||
// unmodified.
|
||||
IrFunction &parentIrFunc = *getIrFunc(parentFunc);
|
||||
irFunc.frameType = parentIrFunc.frameType;
|
||||
irFunc.frameTypeAlignment = parentIrFunc.frameTypeAlignment;
|
||||
irFunc.depth = parentIrFunc.depth;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::println("has nested frame");
|
||||
|
||||
// construct nested variables array
|
||||
// start with adding all enclosing parent frames until a static parent is
|
||||
// reached
|
||||
|
||||
|
@ -428,17 +442,6 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
|
|||
// Store type in IrFunction
|
||||
irFunc.frameType = frameType;
|
||||
irFunc.frameTypeAlignment = builder.overallAlignment();
|
||||
} else // no captured variables
|
||||
{
|
||||
if (parentFunc) {
|
||||
// Propagate context arg properties if the context arg is passed on
|
||||
// unmodified.
|
||||
IrFunction &parentIrFunc = *getIrFunc(parentFunc);
|
||||
irFunc.frameType = parentIrFunc.frameType;
|
||||
irFunc.frameTypeAlignment = parentIrFunc.frameTypeAlignment;
|
||||
irFunc.depth = parentIrFunc.depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DtoCreateNestedContext(FuncDeclaration *fd) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue