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

Replace argument with pre-sized array #2925

Closed

Conversation

kang-hl
Copy link

@kang-hl kang-hl commented Aug 1, 2023

Replace argument with pre-sized array

@harawata
Copy link
Member

harawata commented Aug 1, 2023

Hello @kang-hl ,

You submitted #2924 and then submit #2925 (this one).
You have to choose one of them and explain why.

I remembered that there was a lengthy discussion about this topic.
https://stackoverflow.com/q/174093/1261766
I am not particularly interested in this type of micro-optimization, but someone else might pick up.

@guoweixin
Copy link

看一下

@tanpenggood
Copy link
Contributor

haha, using toArray (new Class<?>[0]) or toArray (new Class<?>[list.size()]) is an interesting topic.

@hazendaz
Copy link
Member

closing as same issue, the other way around in spotbugs to remove the older check was raised as likely how user seen this here. Processing power as noted, its better to be zero based and since java 6 written better. The direct size though does take away a small impact to garbage collection only but it does not seem to be worthwhile to matter given its empty to start with. So this PR is not worth applying.

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.

None yet

5 participants