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

Minor code optimizations #634

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

Conversation

Chazoshtare
Copy link
Contributor

@Chazoshtare Chazoshtare commented Aug 10, 2021

There are multiple minor optimizations applied in this PR, either relevant to code performance or readability, explained in detail in commit messages when applicable.

  • Pre-sized toArray calls are changed to zero-sized
  • contains->get declarations changed to getOrDefault
  • if->equals changed to switch
  • a few conditions are simplified

@wcko87
Copy link
Contributor

wcko87 commented Aug 12, 2021

I don't think large pull requests are a good idea, they should be broken up into small changes.

@Chazoshtare
Copy link
Contributor Author

In that case I moved the biggest refactoring change to a different PR, I'll just leave smaller ones here.

@Chazoshtare Chazoshtare changed the title Code refactor and optimizations Minor code optimizations Aug 12, 2021
@Chazoshtare Chazoshtare force-pushed the feature/minor-optimizations branch 2 times, most recently from 354bdf8 to d387dbd Compare September 8, 2021 18:52
With current JDK optimizations, in vast majority of usecases it's better to pass a zero-sized array, as the operation is going to have at most the same, and in some cases better performance than with a pre-sized array. It also results in a shorter declaration.
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.

2 participants