-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Chore/minor clean ups 6 #4523
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
Chore/minor clean ups 6 #4523
Conversation
| this.source = source; | ||
| this.metadata = new LinkedHashMap<>(); | ||
| metadata.forEach(this.metadata::put); | ||
| for (Map.Entry<String, String> entry : metadata.entrySet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should fix possible performance issues with metadata.forEach(this.metadata::put);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why there is a performance issue with the forEach but not with for loop? It is calling the same put method and I don't expect many entries here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having metadata.forEach(this.metadata::put); IntelliJ will complain about possible performance issues and suggest you to use this.metadata.putAll(metadata). If used, this will make a result map immutable and will brake the logic, so for example HazelcastEventStoreTest will go in a never ending loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so for performance, putAll is better than putting each one separately... but for loop is not better than forEach, it just hides it from IntelliJ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, it prevents possible "small enhancement" braking the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No description provided.