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

Add initial capacity to List and Compound tags #60

Merged
merged 4 commits into from
Apr 27, 2021

Conversation

urielsalis
Copy link
Contributor

Background

While running some profiling test on some high performance code using the library we found some simple optimizations :)

Problem

Resizing the backing collections for CompoundTag and ListTag can be expensive(Its a O(N) operation)

Goal

Add initial capacity constructors to both classes, so if you already know the size you can create it directly with that size and avoid the resizing :D

Implementation

Add new constructors that set the initial capacity

Caveats

None.

Further considerations

None.

ToDo list

None.

@urielsalis
Copy link
Contributor Author

Intellij autoformatter did some extra changes, let me know if you want me to revert them or its fine to leave them as is :)

@coveralls
Copy link

coveralls commented Apr 9, 2021

Coverage Status

Coverage increased (+0.07%) to 78.283% when pulling 4021aaa on urielsalis:add-initial-capacity into f05f37f on Querz:master.

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
@Querz
Copy link
Owner

Querz commented Apr 27, 2021

lgtm

@Querz Querz merged commit dae8357 into Querz:master Apr 27, 2021
@urielsalis urielsalis deleted the add-initial-capacity branch April 27, 2021 08:22
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

4 participants