Closed urielsalis closed 3 years ago
While running some profiling test on some high performance code using the library we found some simple optimizations :)
Resizing the backing collections for CompoundTag and ListTag can be expensive(Its a O(N) operation)
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
Add new constructors that set the initial capacity
None.
Intellij autoformatter did some extra changes, let me know if you want me to revert them or its fine to leave them as is :)
Coverage increased (+0.07%) to 78.283% when pulling 4021aaae1b62c68dd4e9f6b77e9d3b7f0471f2fc on urielsalis:add-initial-capacity into f05f37f6675e81b5263a31f660e65895283b05d7 on Querz:master.
lgtm
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.