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

use subList().clear instead of a loop of remove(0) #142

Closed
wants to merge 1 commit into from

Conversation

XenoAmess
Copy link
Contributor

use subList().clear instead of a loop of remove(0)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 90.56% when pulling 5603fb7 on XenoAmess:use_subList().clear into 715d89d on apache:master.

@XenoAmess
Copy link
Contributor Author

Well IMO this can improve the speed as:

  1. in most times the list is an ArrayList here in your codes.
  2. when in original codes, each time you remove(0) it calls a System.arraycopy, means the array is copied extra times.
  3. when use sublist.clear(), it actually called list.removeRange, which do only one System.arraycopy, thus far faster.

@XenoAmess
Copy link
Contributor Author

Hi. do I need a performance benchmark for this pr too?

@asfgit asfgit closed this in d8ad317 Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants