Merge pull request #207 from yueh/performance-optimizations
Some performance or memory optimizations
This commit is contained in:
commit
e1627734b1
25 changed files with 86 additions and 80 deletions
|
@ -33,7 +33,7 @@ import appeng.core.localization.ButtonToolTips;
|
|||
public class GuiImgButton extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
class EnumPair
|
||||
static class EnumPair
|
||||
{
|
||||
|
||||
final Enum setting;
|
||||
|
@ -63,7 +63,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
|
|||
|
||||
}
|
||||
|
||||
class BtnAppearance
|
||||
static class BtnAppearance
|
||||
{
|
||||
|
||||
public int index;
|
||||
|
|
|
@ -23,7 +23,7 @@ public class RenderBlocksWorkaround extends RenderBlocks
|
|||
public EnumSet<ForgeDirection> renderFaces = EnumSet.allOf( ForgeDirection.class );
|
||||
public EnumSet<ForgeDirection> faces = EnumSet.allOf( ForgeDirection.class );
|
||||
|
||||
private class LightingCache implements ISimplifiedBundle
|
||||
private static class LightingCache implements ISimplifiedBundle
|
||||
{
|
||||
|
||||
public IIcon rXPos;
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
|
|||
|
||||
static private long autoBase = Long.MIN_VALUE;
|
||||
|
||||
class InvTracker
|
||||
static class InvTracker
|
||||
{
|
||||
|
||||
final long which = autoBase++;
|
||||
|
@ -76,7 +76,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
|
|||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
class PatternInvSlot extends WrapperInvSlot
|
||||
static class PatternInvSlot extends WrapperInvSlot
|
||||
{
|
||||
|
||||
public PatternInvSlot(IInventory inv) {
|
||||
|
|
|
@ -196,7 +196,7 @@ public class ApiPart implements IPartHelper
|
|||
}
|
||||
}
|
||||
|
||||
class DefaultPackageClassNameRemapper extends Remapper
|
||||
static class DefaultPackageClassNameRemapper extends Remapper
|
||||
{
|
||||
|
||||
public final HashMap<String, String> inputOutput = new HashMap<String, String>();
|
||||
|
|
|
@ -9,7 +9,7 @@ import appeng.api.features.IWorldGen;
|
|||
public class WorldGenRegistry implements IWorldGen
|
||||
{
|
||||
|
||||
private class TypeSet
|
||||
private static class TypeSet
|
||||
{
|
||||
|
||||
final HashSet<Class<? extends WorldProvider>> badProviders = new HashSet<Class<? extends WorldProvider>>();
|
||||
|
|
|
@ -124,14 +124,14 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
missing.add( what );
|
||||
}
|
||||
|
||||
class twoIntegers
|
||||
static class TwoIntegers
|
||||
{
|
||||
|
||||
public final long perOp = 0;
|
||||
public final long times = 0;
|
||||
}
|
||||
|
||||
final HashMap<String, twoIntegers> opsAndMultiplier = new HashMap<String, twoIntegers>();
|
||||
final HashMap<String, TwoIntegers> opsAndMultiplier = new HashMap<String, TwoIntegers>();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -154,7 +154,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
|
||||
for (String s : opsAndMultiplier.keySet())
|
||||
{
|
||||
twoIntegers ti = opsAndMultiplier.get( s );
|
||||
TwoIntegers ti = opsAndMultiplier.get( s );
|
||||
AELog.crafting( s + " * " + ti.times + " = " + (ti.perOp * ti.times) );
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
|
||||
for (String s : opsAndMultiplier.keySet())
|
||||
{
|
||||
twoIntegers ti = opsAndMultiplier.get( s );
|
||||
TwoIntegers ti = opsAndMultiplier.get( s );
|
||||
AELog.crafting( s + " * " + ti.times + " = " + (ti.perOp * ti.times) );
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
|||
final boolean isCrafting;
|
||||
public int priority = 0;
|
||||
|
||||
class TestLookup
|
||||
static class TestLookup
|
||||
{
|
||||
|
||||
final int slot;
|
||||
|
|
|
@ -13,7 +13,7 @@ public class CompassManager
|
|||
|
||||
public static final CompassManager instance = new CompassManager();
|
||||
|
||||
class CompassRequest
|
||||
static class CompassRequest
|
||||
{
|
||||
|
||||
final int hash;
|
||||
|
|
|
@ -19,7 +19,7 @@ import cpw.mods.fml.common.IWorldGenerator;
|
|||
final public class MeteoriteWorldGen implements IWorldGenerator
|
||||
{
|
||||
|
||||
class myGen implements ICompassCallback
|
||||
static class MyGen implements ICompassCallback
|
||||
{
|
||||
|
||||
double distance = 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
|
|||
public class TickHandler
|
||||
{
|
||||
|
||||
class HandlerRep
|
||||
static class HandlerRep
|
||||
{
|
||||
|
||||
public Queue<AEBaseTile> tiles = new LinkedList<AEBaseTile>();
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
|||
instance = this;
|
||||
}
|
||||
|
||||
class SlightlyBetterSort implements Comparator<String>
|
||||
static class SlightlyBetterSort implements Comparator<String>
|
||||
{
|
||||
|
||||
final Pattern p;
|
||||
|
|
|
@ -33,7 +33,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
{
|
||||
|
||||
class PartTypeIst
|
||||
static class PartTypeIst
|
||||
{
|
||||
|
||||
PartType part;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -31,10 +31,11 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
|||
return !disable;
|
||||
}
|
||||
|
||||
public ShapedRecipe(ItemStack result, Object... recipe) {
|
||||
public ShapedRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
output = result.copy();
|
||||
|
||||
String shape = "";
|
||||
StringBuilder shape = new StringBuilder();
|
||||
int idx = 0;
|
||||
|
||||
if ( recipe[idx] instanceof Boolean )
|
||||
|
@ -57,7 +58,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
|||
for (String s : parts)
|
||||
{
|
||||
width = s.length();
|
||||
shape += s;
|
||||
shape.append( s );
|
||||
}
|
||||
|
||||
height = parts.length;
|
||||
|
@ -67,7 +68,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
|||
while (recipe[idx] instanceof String)
|
||||
{
|
||||
String s = (String) recipe[idx++];
|
||||
shape += s;
|
||||
shape.append( s );
|
||||
width = s.length();
|
||||
height++;
|
||||
}
|
||||
|
@ -75,13 +76,13 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
|||
|
||||
if ( width * height != shape.length() )
|
||||
{
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
ret += tmp + ", ";
|
||||
ret.append( tmp + ", " );
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException( ret );
|
||||
ret.append( output );
|
||||
throw new RuntimeException( ret.toString() );
|
||||
}
|
||||
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
|
@ -97,19 +98,19 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
|||
}
|
||||
else
|
||||
{
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
ret += tmp + ", ";
|
||||
ret.append( tmp + ", " );
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException( ret );
|
||||
ret.append( output );
|
||||
throw new RuntimeException( ret.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
input = new Object[width * height];
|
||||
int x = 0;
|
||||
for (char chr : shape.toCharArray())
|
||||
for (char chr : shape.toString().toCharArray())
|
||||
{
|
||||
input[x++] = itemMap.get( chr );
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
|
|||
return !disable;
|
||||
}
|
||||
|
||||
public ShapelessRecipe(ItemStack result, Object... recipe) {
|
||||
public ShapelessRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
output = result.copy();
|
||||
for (Object in : recipe)
|
||||
{
|
||||
|
@ -34,13 +35,13 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
|
|||
}
|
||||
else
|
||||
{
|
||||
String ret = "Invalid shapeless ore recipe: ";
|
||||
StringBuilder ret = new StringBuilder( "Invalid shapeless ore recipe: " );
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
ret += tmp + ", ";
|
||||
ret.append( tmp + ", " );
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException( ret );
|
||||
ret.append( output );
|
||||
throw new RuntimeException( ret.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,21 +64,21 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
|
|||
|
||||
for (int y = 0; y < rows; y++)
|
||||
{
|
||||
String row = "";
|
||||
StringBuilder row = new StringBuilder();
|
||||
for (int x = 0; x < cols; x++)
|
||||
{
|
||||
if ( inputs.get( y ).get( x ).isAir() )
|
||||
row = row + " ";
|
||||
row.append( " " );
|
||||
else
|
||||
{
|
||||
row = row + first;
|
||||
row.append( first );
|
||||
args.add( first );
|
||||
args.add( inputs.get( y ).get( x ) );
|
||||
|
||||
first++;
|
||||
}
|
||||
}
|
||||
args.add( y, row );
|
||||
args.add( y, row.toString() );
|
||||
}
|
||||
|
||||
ItemStack outIS = output.getItemStack();
|
||||
|
|
|
@ -57,9 +57,10 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
|||
throw new RegistrationError( "Error while adding shapeless recipe." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError {
|
||||
public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
|
||||
for (IIngredient i : inputs)
|
||||
{
|
||||
|
@ -74,26 +75,27 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Platform.isSameItemPrecise( output.getItemStack(),reqOutput );
|
||||
|
||||
return Platform.isSameItemPrecise( output.getItemStack(), reqOutput );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPattern( RecipeHandler h) {
|
||||
String o = "shapeless "+output.getQty()+"\n";
|
||||
public String getPattern(RecipeHandler h)
|
||||
{
|
||||
StringBuilder o = new StringBuilder( "shapeless " + output.getQty() + "\n" );
|
||||
|
||||
o += h.getName(output)+"\n";
|
||||
|
||||
for ( int y = 0; y < inputs.size(); y++ )
|
||||
o.append( h.getName( output ) + "\n" );
|
||||
|
||||
for (int y = 0; y < inputs.size(); y++)
|
||||
{
|
||||
IIngredient i = inputs.get(y);
|
||||
IIngredient i = inputs.get( y );
|
||||
if ( i.isAir() )
|
||||
o += "air"+( y +1 == inputs.size() ? "\n" : " " );
|
||||
o.append( "air" + (y + 1 == inputs.size() ? "\n" : " ") );
|
||||
else
|
||||
o += h.getName(i)+( y +1 == inputs.size() ? "\n" : " " );
|
||||
o.append( h.getName( i ) + (y + 1 == inputs.size() ? "\n" : " ") );
|
||||
}
|
||||
|
||||
return o.trim();
|
||||
|
||||
return o.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -60,17 +60,17 @@ public class VersionChecker implements Runnable
|
|||
yc.setRequestProperty( "User-Agent", "AE2/" + AEConfig.VERSION + " (Channel:" + AEConfig.CHANNEL + "," + MCVersion.replace( " ", ":" ) + ")" );
|
||||
BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream() ) );
|
||||
|
||||
String Version = "";
|
||||
StringBuilder Version = new StringBuilder();
|
||||
String inputLine;
|
||||
|
||||
while ((inputLine = in.readLine()) != null)
|
||||
Version += inputLine;
|
||||
Version.append( inputLine );
|
||||
|
||||
in.close();
|
||||
|
||||
if ( Version.length() > 2 )
|
||||
{
|
||||
JsonElement element = (new JsonParser()).parse( Version );
|
||||
JsonElement element = (new JsonParser()).parse( Version.toString() );
|
||||
|
||||
int version = element.getAsJsonObject().get( "FormatVersion" ).getAsInt();
|
||||
if ( version == 1 )
|
||||
|
|
|
@ -31,12 +31,12 @@ public class StorageHelper
|
|||
return instance;
|
||||
}
|
||||
|
||||
class triggerUpdates implements ISpatialVisitor
|
||||
static class TriggerUpdates implements ISpatialVisitor
|
||||
{
|
||||
|
||||
final World dst;
|
||||
|
||||
public triggerUpdates(World dst2) {
|
||||
public TriggerUpdates(World dst2) {
|
||||
dst = dst2;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class StorageHelper
|
|||
}
|
||||
}
|
||||
|
||||
class WrapInMatrixFrame implements ISpatialVisitor
|
||||
static class WrapInMatrixFrame implements ISpatialVisitor
|
||||
{
|
||||
|
||||
final World dst;
|
||||
|
@ -68,7 +68,7 @@ public class StorageHelper
|
|||
}
|
||||
}
|
||||
|
||||
class TelDestination
|
||||
static class TelDestination
|
||||
{
|
||||
|
||||
TelDestination(World _dim, AxisAlignedBB srcBox, double _x, double _y, double _z, int tileX, int tileY, int tileZ) {
|
||||
|
@ -91,7 +91,7 @@ public class StorageHelper
|
|||
final int zOff;
|
||||
}
|
||||
|
||||
class METeleporter extends Teleporter
|
||||
static class METeleporter extends Teleporter
|
||||
{
|
||||
|
||||
final TelDestination dest;
|
||||
|
@ -303,11 +303,11 @@ public class StorageHelper
|
|||
for (WorldCoord wc : cSrc.updates)
|
||||
cSrc.world.notifyBlockOfNeighborChange( wc.x, wc.y, wc.z, Platform.air );
|
||||
|
||||
transverseEdges( x - 1, y - 1, z - 1, x + scaleX + 1, y + scaleY + 1, z + scaleZ + 1, new triggerUpdates( src ) );
|
||||
transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new triggerUpdates( dst ) );
|
||||
transverseEdges( x - 1, y - 1, z - 1, x + scaleX + 1, y + scaleY + 1, z + scaleZ + 1, new TriggerUpdates( src ) );
|
||||
transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new TriggerUpdates( dst ) );
|
||||
|
||||
transverseEdges( x, y, z, x + scaleX, y + scaleY, z + scaleZ, new triggerUpdates( src ) );
|
||||
transverseEdges( i, j, k, i + scaleX, j + scaleY, k + scaleZ, new triggerUpdates( dst ) );
|
||||
transverseEdges( x, y, z, x + scaleX, y + scaleY, z + scaleZ, new TriggerUpdates( src ) );
|
||||
transverseEdges( i, j, k, i + scaleX, j + scaleY, k + scaleZ, new TriggerUpdates( dst ) );
|
||||
|
||||
/*
|
||||
* IChunkProvider cp = dest.getChunkProvider(); if ( cp instanceof ChunkProviderServer ) { ChunkProviderServer
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack;
|
|||
public class WrapperChainedInventory implements IInventory
|
||||
{
|
||||
|
||||
class InvOffset
|
||||
static class InvOffset
|
||||
{
|
||||
|
||||
int offset;
|
||||
|
|
|
@ -13,7 +13,7 @@ public class OreHelper
|
|||
|
||||
public static final OreHelper instance = new OreHelper();
|
||||
|
||||
class ItemRef
|
||||
static class ItemRef
|
||||
{
|
||||
|
||||
ItemRef(ItemStack stack)
|
||||
|
@ -51,7 +51,7 @@ public class OreHelper
|
|||
|
||||
}
|
||||
|
||||
class OreResult
|
||||
static class OreResult
|
||||
{
|
||||
|
||||
public OreReference oreValue = null;
|
||||
|
|
Loading…
Reference in a new issue