-
Notifications
You must be signed in to change notification settings - Fork 281
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
Development
: Refactor bad code smell in list to array conversion
#5885
Development
: Refactor bad code smell in list to array conversion
#5885
Conversation
- ToArrayCallWithZeroLengthArrayArgument The performance of the empty array version is the same, and sometimes even better, compared to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the <code>size</code> and <code>toArray</code> calls. This may result in extra <code>null</code>s at the end of the array if the collection was concurrently shrunk during the operation.</p> See https://shipilev.net/blog/2016/arrays-wisdom-ancients/ for more details.
Development
: refactor bad smell ToArrayCallWithZeroLengthArrayArgument
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.
Thank you!
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.
According to your own tool there are more instances of this code smell in the source code, e.g. in ConversationService.java:79
. It would be great if you could adress all of them in one PR.
Codecov ReportBase: 75.63% // Head: 79.92% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #5885 +/- ##
=============================================
+ Coverage 75.63% 79.92% +4.28%
- Complexity 0 12354 +12354
=============================================
Files 1117 2125 +1008
Lines 44289 84225 +39936
Branches 8364 12633 +4269
=============================================
+ Hits 33499 67313 +33814
- Misses 5621 9385 +3764
- Partials 5169 7527 +2358
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
src/main/java/de/tum/in/www1/artemis/service/metis/ConversationService.java
Outdated
Show resolved
Hide resolved
…nService.java Co-authored-by: Lucas Welscher <micky.321@web.de>
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.
Thanks for your contribution! 🎉
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.
Code changes look good to me
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.
Code LGTM. Nice code quality improvement.
Development
: refactor bad smell ToArrayCallWithZeroLengthArrayArgumentDevelopment
: Refactor bad code smell in list to array conversion
Repairing Code Style Issues
ToArrayCallWithZeroLengthArrayArgument
The performance of the empty array version is the same, and sometimes even better, compared
to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or
synchronized collection as a data race is possible between the
size
andtoArray
calls. This may result in extra
null
s at the end of the array if the collection was concurrentlyshrunk during the operation.
See https://shipilev.net/blog/2016/arrays-wisdom-ancients/ for more details.
Repairing Code Style Issues