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

refactored by concatenating String to be appended to StringBuilder #68

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

Conversation

Shivangip285
Copy link

Refactor

@karussell
Copy link
Member

karussell commented Nov 3, 2022

Thanks for your contribution. Unfortunately I do not understand the intend of the refactoring. What do you think has improved with it? Why e.g. is append replaced with String concatenation?

PS: I fixed the build in the master branch

@Shivangip285
Copy link
Author

Shivangip285 commented Nov 3, 2022 via email

@karussell
Copy link
Member

I had preferred concatenation of static String with dynamic String followed by append,

In non-performance critical code this is indeed better readable, but I would keep it as it is here. Also you shouldn't mix append and +.

collectively they will help improving performance and keeping the code clean

improving performance is only possible if you measure your results. You shouldn't change code only because you think it is faster (e.g. use JMH or apache bench). Also from my experience it does not matter if you use append or + although append was slightly faster in previous JVM versions, but I'm unsure why + should be faster. Also a variable like rsp that is immediately returned is not a performance problem.

this is optimized replacement of 3 line of if block with Math.min()

Ok

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