Skip to content

Conversation

Frotty
Copy link
Member

@Frotty Frotty commented Aug 2, 2018

Removes empty package init functions, see #511

@Frotty Frotty requested a review from peq August 2, 2018 16:08
@coveralls
Copy link

coveralls commented Aug 2, 2018

Coverage Status

Coverage increased (+0.06%) to 60.856% when pulling 0d5aaef on remove-empty-inits into 6e3ef1e on master.

Doesn't allocate handles
Copy link
Collaborator

@peq peq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be easier to improve the generation of the bridge-functions instead of trying to find and optimize them after the fact?

initFuncs.forEach(func -> {
ImVar globalBridge = null;
for (ImVar global : prog.getGlobals()) {
if (global.getName().equals("ref_function_" + func.getName())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like using the name here. Names should not matter in the intermediate language.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What to use then?

List<ImFunction> initFuncs = prog.getFunctions().stream().filter(func -> func.getName().startsWith
("init_") && func.getBody().size() == 1).collect(Collectors.toList());

initFuncs.forEach(func -> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use normal for-loops -- better performance, better stack traces, better debugging, easier to read

if (body.get(finalI - 1) instanceof ImFunctionCall) {
body.get(finalI - 1).replaceBy(JassIm.ImNull());
}
body.get(finalI + 1).replaceBy(JassIm.ImNull());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the -1 and +1 doing here? Looks like you are assuming that there are always certain other statements around a call to TriggerAddCondition but that does not seem very reliable to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init calls are always generated the same way. Unless someone names a function "ref_function_" or so (which is the name issue above) then it seems reliable to me.

@Frotty
Copy link
Member Author

Frotty commented Aug 8, 2018

Would it not be easier to improve the generation of the bridge-functions instead of trying to find and optimize them after the fact?

No idea where to start with that tbh. The old ticket & solution have been around for a while, this is one without inlining again.

@Frotty
Copy link
Member Author

Frotty commented Aug 20, 2018

@peq ?

@Frotty Frotty closed this Sep 27, 2019
@Frotty Frotty deleted the remove-empty-inits branch February 16, 2020 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants