-
-
Notifications
You must be signed in to change notification settings - Fork 979
Fix minor warnings #1863
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
Fix minor warnings #1863
Conversation
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 the PR @Captain1653.
I have some comments about it though.
Regarding the changes for changing the for
loops with Collectors.toList()
. There is one small performance problem about it. The performance is linked with the size of the list.
For example
List<String> strings = createStrings();
List<Integer> result = new ArrayList<>( strings.size() );
for (String string: strings) {
result.add( Integer.parse( string ) );
}
vs
List<String> strings = createStrings();
List<Integer> result = strings.stream().map( Integer::parse ).collect( Collectors.toList() );
Both are semantically the same. However, in the first approach the result list is created with the expected size and in the second one it isn't. This means that when creating the result
there will be a lot of expansions of the underlying array in ArrayList
. In theory this could be done with Collectors.tolCollection( () -> new ArrayList( strings.size() ) )
. However, I am not sure whether that is better or not.
It is similar for doing the remove in the getThrownTypes()
@filiphr P.S. From javadoc ArrayList java 8:
|
I think that for the time being it is better to leave the for loops as is. Not following what you mean about the javadoc. |
remove unnecessary generic type for collections, replace Charset.forName on StandartCharset
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 applying the changes @Captain1653. Will merge it once the build is done
Fix minor warnings:
remove unnecessary generic type for collections,
replace Charset.forName on StandartCharsets