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:
yueh
2014-09-30 22:59:49 +02:00
parent d8da97d2af
commit 7fa7e43c29
25 changed files with 86 additions and 80 deletions
+4 -3
View File
@@ -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() );