perf fixes

This commit is contained in:
Paul Chote
2010-04-01 23:21:01 +13:00
committed by Bob
parent c366b7c7fc
commit 3b15aec294
3 changed files with 39 additions and 19 deletions

View File

@@ -88,11 +88,8 @@ namespace OpenRA.FileFormats
public byte[] GetBytes(TileReference<ushort,byte> r)
{
Terrain tile;
try {
if( tiles.TryGetValue( r.type, out tile ) )
return tile.TileBitmapBytes[ r.image ];
}
catch (System.ArgumentOutOfRangeException) { }
if( tiles.TryGetValue( r.type, out tile ) )
return tile.TileBitmapBytes[ r.image ];
byte[] missingTile = new byte[ 24 * 24 ];
for( int i = 0 ; i < missingTile.Length ; i++ )
@@ -101,16 +98,13 @@ namespace OpenRA.FileFormats
return missingTile;
}
public TerrainType GetTerrainType(TileReference<ushort,byte> r)
{
try {
return walk[r.type].TerrainType[r.image];
}
catch (KeyNotFoundException)
{
return 0; // Default zero (walkable)
}
public TerrainType GetTerrainType( TileReference<ushort, byte> r )
{
var tt = walk[ r.type ].TerrainType;
TerrainType ret;
if( !tt.TryGetValue( r.image, out ret ) )
return 0;// Default zero (walkable)
return ret;
}
}
}