-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MC1.16] [Client] Performance improvements for grid view (#2705)
* Make Crafting Manager AND search terms, not OR them Plus refactor getFilters to avoid passing raw lists of filters around and instead use GridFilter objects that combine conditions through OR and AND. * Don't make all items vanish if query ends in `|` * Split out Comparator and Predicate generation for GridView into 2 separate functions * Move common code up into BaseGridView; remove identical subclasses This also follows the Law of Demeter a litle better. * Avoid sorting entire grid view on single item update Instead, use binary search and insert. * Ensure crafting stack is removed/inserted to complement original stack
- Loading branch information
1 parent
6b8daf1
commit 74ab430
Showing
20 changed files
with
285 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/refinedmods/refinedstorage/screen/grid/filtering/AndGridFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.refinedmods.refinedstorage.screen.grid.filtering; | ||
|
||
import com.refinedmods.refinedstorage.screen.grid.stack.IGridStack; | ||
|
||
import java.util.List; | ||
import java.util.function.Predicate; | ||
|
||
public class AndGridFilter implements Predicate<IGridStack> { | ||
private final List<Predicate<IGridStack>> andPartFilters; | ||
|
||
private AndGridFilter(List<Predicate<IGridStack>> andPartFilters) { | ||
this.andPartFilters = andPartFilters; | ||
} | ||
|
||
@Override | ||
public boolean test(IGridStack gridStack) { | ||
for (Predicate<IGridStack> part : andPartFilters) { | ||
if (!part.test(gridStack)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public static Predicate<IGridStack> of(List<Predicate<IGridStack>> filters) { | ||
if (filters.isEmpty()) { | ||
return t -> true; | ||
} | ||
if (filters.size() == 1) { | ||
return filters.get(0); | ||
} | ||
return new AndGridFilter(filters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.