Attempted to fix FPS drop on Grid sorting, fixes #1674
This commit is contained in:
		@@ -11,6 +11,7 @@
 | 
			
		||||
- Fixed Disk Manipulator being stuck on unemptiable, non-empty disks (ineternet)
 | 
			
		||||
- Fixed orientations of the Portable Grid (TeamSpen210)
 | 
			
		||||
- Fixed crafting event in Crafting Grid being fired twice (raoulvdberge)
 | 
			
		||||
- Attempted to fix FPS drop on Grid sorting (raoulvdberge)
 | 
			
		||||
- Disk Manipulator in fluid mode will now extract a bucket at a time instead of 1 mB (or 64 buckets at a time with a Stack Upgrade instead of 64 mB) (raoulvdberge)
 | 
			
		||||
 | 
			
		||||
### 1.5.31
 | 
			
		||||
 
 | 
			
		||||
@@ -62,8 +62,8 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
			
		||||
    public static List<IGridStack> STACKS = new ArrayList<>();
 | 
			
		||||
    public static boolean CAN_CRAFT;
 | 
			
		||||
 | 
			
		||||
    private static boolean SCHEDULE_SORT = false;
 | 
			
		||||
    private Queue<Sorter> sortingQueue = new ArrayDeque<>();
 | 
			
		||||
    private static final Sorter SORTER = new Sorter();
 | 
			
		||||
    private static boolean SCHEDULE_SORT;
 | 
			
		||||
 | 
			
		||||
    private boolean wasConnected;
 | 
			
		||||
 | 
			
		||||
@@ -210,16 +210,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
			
		||||
        if (SCHEDULE_SORT) {
 | 
			
		||||
            SCHEDULE_SORT = false;
 | 
			
		||||
 | 
			
		||||
            sortingQueue.add(new Sorter(this));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Sorter sorter = sortingQueue.peek();
 | 
			
		||||
        if (sorter != null) {
 | 
			
		||||
            if (!sorter.isStarted()) {
 | 
			
		||||
                sorter.start();
 | 
			
		||||
            } else if (sorter.isDone()) {
 | 
			
		||||
                sortingQueue.poll();
 | 
			
		||||
            }
 | 
			
		||||
            SORTER.startIfPossible(this);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,15 +18,10 @@ public class Sorter implements Runnable {
 | 
			
		||||
    private static final GridSorting SORTING_INVENTORYTWEAKS = new GridSortingInventoryTweaks();
 | 
			
		||||
    private static final GridSorting SORTING_LAST_MODIFIED = new GridSortingLastModified();
 | 
			
		||||
 | 
			
		||||
    private boolean done;
 | 
			
		||||
    private boolean started;
 | 
			
		||||
    private boolean busy;
 | 
			
		||||
 | 
			
		||||
    private GuiGrid gui;
 | 
			
		||||
 | 
			
		||||
    public Sorter(GuiGrid gui) {
 | 
			
		||||
        this.gui = gui;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void run() {
 | 
			
		||||
        IGrid grid = gui.getGrid();
 | 
			
		||||
@@ -90,20 +85,15 @@ public class Sorter implements Runnable {
 | 
			
		||||
            gui.getTabPageRight().visible = grid.getTotalTabPages() > 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.done = true;
 | 
			
		||||
        this.busy = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void start() {
 | 
			
		||||
        this.started = true;
 | 
			
		||||
    public void startIfPossible(GuiGrid gui) {
 | 
			
		||||
        if (!busy) {
 | 
			
		||||
            this.busy = true;
 | 
			
		||||
            this.gui = gui;
 | 
			
		||||
 | 
			
		||||
        new Thread(this, "RS grid sorting").start();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isStarted() {
 | 
			
		||||
        return started;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isDone() {
 | 
			
		||||
        return done;
 | 
			
		||||
            new Thread(this, "RS grid sorting").start();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user