Avoid quadratic behavior from rebuilding the entire crafting cache for
each interface visited. Instead rebuild it at most once per tick, like cpu clusters. This is particularly important when channels are disabled, since in that case even adding a cable visits every grid node.
This commit is contained in:
+10
-3
@@ -114,6 +114,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
private IStorageGrid storageGrid;
|
||||
private IEnergyGrid energyGrid;
|
||||
private boolean updateList = false;
|
||||
private boolean updatePatterns = false;
|
||||
|
||||
public CraftingGridCache( final IGrid grid )
|
||||
{
|
||||
@@ -138,6 +139,12 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
this.updateCPUClusters();
|
||||
}
|
||||
|
||||
if( this.updatePatterns )
|
||||
{
|
||||
this.updatePatterns = false;
|
||||
this.updatePatterns();
|
||||
}
|
||||
|
||||
final Iterator<CraftingLinkNexus> craftingLinkIterator = this.craftingLinks.values().iterator();
|
||||
while( craftingLinkIterator.hasNext() )
|
||||
{
|
||||
@@ -185,7 +192,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
if( machine instanceof ICraftingProvider )
|
||||
{
|
||||
this.craftingProviders.remove( machine );
|
||||
this.updatePatterns();
|
||||
this.updatePatterns = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +226,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
if( machine instanceof ICraftingProvider )
|
||||
{
|
||||
this.craftingProviders.add( (ICraftingProvider) machine );
|
||||
this.updatePatterns();
|
||||
this.updatePatterns = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +344,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
@MENetworkEventSubscribe
|
||||
public void updateCPUClusters( final MENetworkCraftingPatternChange c )
|
||||
{
|
||||
this.updatePatterns();
|
||||
this.updatePatterns = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user