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

Commits on Apr 23, 2021

  1. Fix strlen redundancy

    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.
    TheCasachii committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    9a22d74 View commit details
    Browse the repository at this point in the history
  2. Remove repeated blocks of code

    In calculator.c, there are identical blocks of code repeated several times. This commit extracts them into functions and calls them instead.
    TheCasachii committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    6f911bb View commit details
    Browse the repository at this point in the history
  3. Remove redundant tokenType calls

    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.
    TheCasachii committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    9cd151a View commit details
    Browse the repository at this point in the history
  4. Remove unused functions

    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.
    TheCasachii committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    e1df36d View commit details
    Browse the repository at this point in the history
  5. Shorten type(char) massively

    This commit removes all cases 0-9 and A-Z from the switch and performs short IFs in the default case instead.
    TheCasachii committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    1add01b View commit details
    Browse the repository at this point in the history