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

Remove unused local variables/expressions #63

Open
Woccz opened this issue Jun 19, 2021 · 1 comment
Open

Remove unused local variables/expressions #63

Woccz opened this issue Jun 19, 2021 · 1 comment
Labels
backlog Good idea but bad effort to value ratio right now enhancement New feature or request

Comments

@Woccz
Copy link
Contributor

Woccz commented Jun 19, 2021

Any local variable or expression that has no effect on a global variable can be removed.

i.e.

  • Is never assigned to a global, or recursively to a local which is assigned to a global.
  • Is never evaluated:
    • in if
    • in runtime error generator

The first implementation of this could merely remove any locals that are never evaluated, in any context.

image

Note: Obviously, any competent programmer can remove useless expressions from their code, but with libraries and other code reusability(e.g. #62), this maybe be a helpful optimisation.

Thank you.

@Woccz Woccz added the enhancement New feature or request label Jun 19, 2021
@dbaumgarten
Copy link
Owner

Finding out of a variable somehow influences a global should be possible, but probably requires some effort to do it properly.
Removing assignments to variables that er never referenced would be a good first step.

Given that this will not be used very often and would require relatively much work: backlog

@dbaumgarten dbaumgarten added the backlog Good idea but bad effort to value ratio right now label Jun 20, 2021
@Woccz Woccz changed the title [Optimisation] Remove unused local variables/expressions Remove unused local variables/expressions Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Good idea but bad effort to value ratio right now enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants