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 code redundancy #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Remove code redundancy #23

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 23, 2021

This PR removes unused code, repeated function calls and unnecessary repetition.

TheCasachii added 5 commits April 23, 2021 08:44
Use of strlen requires full traversal of the string on every call. In calculator.c, strlen was used multiple times on the same string, which, when dealing with long tokens, could result in a performance bottleneck. This commit fixes the issue by storing necessary string lengths in a variable, which is then reused when needed.
In calculator.c, there are identical blocks of code repeated several times. This commit extracts them into functions and calls them instead.
This commit removes unnecessary calls to tokenType. In many places (especially IF statements) the tokenType calls have the same parameters and can be replaced with a pre-loaded value in a variable.

This commit also removes repetition from the `counter = 1` assignment.
This commit removes a big chunk of code that was never used - functions substr, strBeginsWith and toDigit. The last one was only used inside some commented code and there was no mention of the other functions in code.
This commit removes all cases 0-9 and A-Z from the switch and performs short IFs in the default case instead.
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.

None yet

0 participants