Some performance or memory optimizations
Replaced String concat in loops with StringBuilder (performance) Replaced for with keySet + Map.get() through for with entrySet (perf) Changed inner classes to static classes, mostly struct like (memory)
This commit is contained in:
@@ -3,6 +3,7 @@ package appeng.me;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -34,10 +35,10 @@ public class Grid implements IGrid
|
||||
this.pivot = center;
|
||||
|
||||
HashMap<Class<? extends IGridCache>, IGridCache> myCaches = AEApi.instance().registries().gridCache().createCacheInstance( this );
|
||||
for (Class<? extends IGridCache> c : myCaches.keySet())
|
||||
for (Entry<Class<? extends IGridCache>, IGridCache> c : myCaches.entrySet())
|
||||
{
|
||||
bus.readClass( c, myCaches.get( c ).getClass() );
|
||||
caches.put( c, new GridCacheWrapper( myCaches.get( c ) ) );
|
||||
bus.readClass( c.getKey(), c.getValue().getClass() );
|
||||
caches.put( c.getKey(), new GridCacheWrapper( c.getValue() ) );
|
||||
}
|
||||
|
||||
postEvent( new MENetworkPostCacheConstruction() );
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -14,7 +15,7 @@ import appeng.core.AELog;
|
||||
public class NetworkEventBus
|
||||
{
|
||||
|
||||
class NetworkEventDone extends Throwable
|
||||
static class NetworkEventDone extends Throwable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -3079021487019171205L;
|
||||
@@ -129,17 +130,17 @@ public class NetworkEventBus
|
||||
{
|
||||
if ( subscribers != null )
|
||||
{
|
||||
for (Class o : subscribers.keySet())
|
||||
for (Entry<Class, MENetworkEventInfo> subscriber : subscribers.entrySet())
|
||||
{
|
||||
MENetworkEventInfo target = subscribers.get( o );
|
||||
GridCacheWrapper cache = g.caches.get( o );
|
||||
MENetworkEventInfo target = subscriber.getValue();
|
||||
GridCacheWrapper cache = g.caches.get( subscriber.getKey() );
|
||||
if ( cache != null )
|
||||
{
|
||||
x++;
|
||||
target.invoke( cache.myCache, e );
|
||||
}
|
||||
|
||||
for (IGridNode obj : g.getMachines( o ))
|
||||
for (IGridNode obj : g.getMachines( subscriber.getKey() ))
|
||||
{
|
||||
x++;
|
||||
target.invoke( obj.getMachine(), e );
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
final private SetMultimap<IAEStack, CraftingWatcher> interests = HashMultimap.create();
|
||||
final public GenericInterestManager<CraftingWatcher> interestManager = new GenericInterestManager<CraftingWatcher>( interests );
|
||||
|
||||
class ActiveCpuIterator implements Iterator<ICraftingCPU>
|
||||
static class ActiveCpuIterator implements Iterator<ICraftingCPU>
|
||||
{
|
||||
|
||||
final Iterator<CraftingCPUCluster> i;
|
||||
|
||||
@@ -58,7 +58,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
{
|
||||
|
||||
class TaskProgress
|
||||
static class TaskProgress
|
||||
{
|
||||
|
||||
long value;
|
||||
|
||||
@@ -27,7 +27,7 @@ import appeng.util.inv.ItemSlot;
|
||||
public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonitor<IAEItemStack>
|
||||
{
|
||||
|
||||
class CachedItemStack
|
||||
static class CachedItemStack
|
||||
{
|
||||
|
||||
public CachedItemStack(ItemStack is)
|
||||
|
||||
Reference in New Issue
Block a user