Chisels & Bits - For Fabric

Chisels & Bits - For Fabric

2M Downloads

Minor improvement

LatvianModder opened this issue ยท 5 comments

commented

https://github.com/AlgorithmX2/Chisels-and-Bits/blob/1.12/src/main/java/mod/chiselsandbits/render/chiseledblock/ChiseledBlockBaked.java#L162

Would it be a bit faster if this was if(array == null || array.length == 0)? I think it would. Otherwise it creates new array list for every empty array too

commented

Ah, I see. Nevermind then

commented

How much better is using arrays instead of lists? I thought a list from Arrays.asList() basically only costs extra 8 bytes or whatever for reference, and List<BakedQuad> getList() would be faster

commented

I made this selection after doing various profiling and measurements. Using arrays rather then arraylists used less memory consistently as the arraylists are never promoted to longer term memory and are collected much more consistently. By comparison using permanent array lists inflated constant memory usage consistently.

It seems a little backwards, but these are the results of the tests and experimentation I did to improve memory efficiency.

commented

The main point of concern here is that while yes, keeping those arraylists around would save some cpu time, wrapping them on demand can make for significant ( not immediately obvious ) savings for large C&B structure with 100's if not 1000's of distinct models.