Skip to content

Commit

Permalink
gac: avoid redundant final return
Browse files Browse the repository at this point in the history
When coding functions we already ensure there is a final
`return` statement in there, so there is no need for gac
to add yet another.
  • Loading branch information
fingolfin committed Jan 4, 2025
1 parent 9438741 commit d89dff3
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 237 deletions.
5 changes: 0 additions & 5 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -5163,11 +5163,6 @@ static void CompFunc(Obj func)
// compile the body
CompStat( OFFSET_FIRST_STAT );

// emit the code to switch back to the old frame and return
Emit( "\n/* return; */\n" );

Emit( "SWITCH_TO_OLD_FRAME(oldFrame);\n" );
Emit( "return 0;\n" );
Emit( "}\n" );

// switch back to old frame
Expand Down
32 changes: 0 additions & 32 deletions tst/test-compile/and_filter.g.dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ static Obj HdlrFunc3 (
}
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 4 */
Expand All @@ -78,10 +74,6 @@ static Obj HdlrFunc4 (
}
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 5 */
Expand Down Expand Up @@ -120,10 +112,6 @@ static Obj HdlrFunc5 (
}
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 6 */
Expand Down Expand Up @@ -162,10 +150,6 @@ static Obj HdlrFunc6 (
}
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 7 */
Expand Down Expand Up @@ -198,10 +182,6 @@ static Obj HdlrFunc7 (
}
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 8 */
Expand All @@ -228,10 +208,6 @@ static Obj HdlrFunc8 (
}
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 2 */
Expand Down Expand Up @@ -460,10 +436,6 @@ static Obj HdlrFunc2 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 1 */
Expand Down Expand Up @@ -514,10 +486,6 @@ static Obj HdlrFunc1 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* 'PostRestore' restore gvars, rnams, functions */
Expand Down
8 changes: 0 additions & 8 deletions tst/test-compile/assert.g.dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ static Obj HdlrFunc2 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 1 */
Expand Down Expand Up @@ -243,10 +239,6 @@ static Obj HdlrFunc1 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* 'PostRestore' restore gvars, rnams, functions */
Expand Down
48 changes: 0 additions & 48 deletions tst/test-compile/basics.g.dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,6 @@ static Obj HdlrFunc2 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 4 */
Expand All @@ -320,10 +316,6 @@ static Obj HdlrFunc4 (
C_LEN_LIST_FPL( t_1, a_args )
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 5 */
Expand Down Expand Up @@ -351,10 +343,6 @@ static Obj HdlrFunc5 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 3 */
Expand Down Expand Up @@ -749,10 +737,6 @@ static Obj HdlrFunc3 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 6 */
Expand Down Expand Up @@ -1434,10 +1418,6 @@ static Obj HdlrFunc6 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 7 */
Expand Down Expand Up @@ -1470,10 +1450,6 @@ static Obj HdlrFunc7 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 8 */
Expand All @@ -1490,10 +1466,6 @@ static Obj HdlrFunc8 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 9 */
Expand Down Expand Up @@ -1744,10 +1716,6 @@ static Obj HdlrFunc9 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 10 */
Expand Down Expand Up @@ -2093,10 +2061,6 @@ static Obj HdlrFunc10 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 11 */
Expand Down Expand Up @@ -2289,10 +2253,6 @@ static Obj HdlrFunc11 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 12 */
Expand Down Expand Up @@ -2391,10 +2351,6 @@ static Obj HdlrFunc12 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* handler for function 1 */
Expand Down Expand Up @@ -2792,10 +2748,6 @@ static Obj HdlrFunc1 (
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;

/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}

/* 'PostRestore' restore gvars, rnams, functions */
Expand Down
Loading

0 comments on commit d89dff3

Please sign in to comment.