Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Ignore unreferenced named parameters #151

Merged
merged 2 commits into from Oct 1, 2020
Merged

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented May 23, 2020

When a named parameter is defined, it consumes an actionD register, even if it's never accessed later.

This PR solves that by reference counting all identifiers, and assign an actionD register only if it's needed.

The check is not recursive, a named parameter referenced only by an unreferenced one won't be ignored. Same for write only named parameters written multiple times. But I think these cases should not be common.

nml/actions/actionD.py Show resolved Hide resolved
It's not recursive, a param referenced only by a unreferenced one won't be ignored.
Copy link
Contributor

@FLHerne FLHerne left a comment

Looks good to me, Eddi's potential issue aside.

I suspect the simple refcounting can have some false negatives, because of Identifiers being used for other things, but that shouldn't be a problem.

@glx22
Copy link
Contributor Author

@glx22 glx22 commented May 24, 2020

Yeah it's a very basic optimisation, but it should handle all simple cases and free some actionD registers.

Anyway, please do not merge this PR before @Eddi-z can test it :)

@LordAro LordAro merged commit 3add620 into OpenTTD:master Oct 1, 2020
16 checks passed
@glx22 glx22 deleted the identifiers branch Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants