Optimize: entrySet is faster than keySet + get to prevent N lookups#10496
Optimize: entrySet is faster than keySet + get to prevent N lookups#10496wing328 merged 4 commits intoOpenAPITools:masterfrom larrydiamond:master
Conversation
…o get method in a few places
|
Thanks for the PR. cc @OpenAPITools/generator-core-team |
|
@larrydiamond thanks for the PR but CI reports the following errors: Can you please take a look when you've time? |
|
That's very odd, I will take a look. My apologies, maybe I missed a commit in there. |
|
My apologies, I compiled using Java 11 which added the StringBuilder method that isnt there in Java 8. I'll remediate this right now with my apologies. |
|
The unit tests have run to completion on my mac using Java 8 now. I checked the three other calls to appendReplacement and two other calls to appendTail and all of the calls are using StringBuffer. |
|
And then the bitrise build failed due to something that looks like it just needs to be retried |
|
No need to apologize. We appreciate your contributions to his project. Bitrise CI failure is not related to this change so don't worry about it. |
|
I'm very happy to help out here! |
This is a series of minor performance boost by replacing the keySet + get calls with entrySet in order to eliminate N lookups in a few places.
In addition, some TreeMap/Set objects were replaced with ConcurrentSkipListMap/Set types which are generally faster and intended to be a replacement when introduced with Java 1.6.
https://www.javacodegeeks.com/2017/04/simple-map-iterator-performance-test.html for some nice charts of the performance differences.
I ran all of the unit tests, and I was a little surprised to see pre-existing PMD issues. I did not add any new ones but there are existing ones.
I did review and follow the contribution guidelines and ran the samples. There were no file changes as a result of running the samples, which did not surprise me as this is a performance improvement only - there should be no changes in any output and there was not.
This contribution is against master, please let me know if I did this against the right branch or if I should be doing this work against a different branch.
This is my first pull request to openapi-generator, please excuse any expected actions I did not perform prior to sending this pull request, I will gladly make any changes to fulfill the process to commit code.
Thank you very much,
Larry Diamond