Refined Storage

Refined Storage

77M Downloads

Too many sorts on Opening Grid

BONNe opened this issue ยท 1 comments

commented

Describe the bug

I have created an addon for mod that adds extra sorting properties for some objects. But when it is used on a huge amount of objects, it starts to take a very noticeable time to open the grid.

For investigation purpose, I added a code call that triggers when elements are sorted, and I found out that opening a Grid triggers 8 sorting calls.

The first two calls are triggered on initialization with an empty object map, and it does not matter.
Then it creates a new list from all object map and sorts the list, as expected.

The weird part happens after that. The sorting is triggered 5 more times after that, and every time it creates a new item list with all objects from the map, and sorts everything again.

The code part where I added a breakpoint is:
https://github.com/refinedmods/refinedstorage/blob/develop/src/main/java/com/refinedmods/refinedstorage/screen/grid/view/GridViewImpl.java#L67-L70

I do not how huge an issue it is, but I think that triggering the sort 5 times when opening a grid on items that are already sorted is a bit weird.

How can we reproduce this bug or crash?

  1. Add a break-point in https://github.com/refinedmods/refinedstorage/blob/develop/src/main/java/com/refinedmods/refinedstorage/screen/grid/view/GridViewImpl.java#L67-L70
  2. Open a grid
  3. Notice that the code is triggered 8 times.

What Minecraft version is this happening on?

Minecraft 1.20.1

What Forge version is this happening on?

47.1.0

What Refined Storage version is this happening on?

v1.12.3

Relevant log output

No response

commented

Hi, thanks for the investigation. I have been looking into this for Refined Storage 2, which is where it will be fixed.