Only write MKFR if there are actually locals

Saves a single instruction, but only sometimes. Woo!
This commit is contained in:
arookas 2016-02-05 01:55:48 -05:00
parent 9749b81452
commit fefb17524c

View file

@ -207,7 +207,10 @@ namespace arookas {
compiler.Context.Scopes.DeclareVariable(parameter); // since there is no AST node for these, they won't affect MaxLocalCount compiler.Context.Scopes.DeclareVariable(parameter); // since there is no AST node for these, they won't affect MaxLocalCount
} }
compiler.Binary.WriteMKDS(1); compiler.Binary.WriteMKDS(1);
compiler.Binary.WriteMKFR(mBody.LocalCount); var locals = mBody.LocalCount;
if (locals > 0) {
compiler.Binary.WriteMKFR(locals);
}
mBody.Compile(compiler); mBody.Compile(compiler);
compiler.Binary.WriteRET0(); compiler.Binary.WriteRET0();
compiler.Context.Scopes.Pop(compiler); compiler.Context.Scopes.Pop(compiler);