Memory footprint: Claims Lookup
Eliminated unwanted chunk loads from claim lookups and boot process. Also a slight perf improvement for claim lookup.
This commit is contained in:
parent
549ae3441f
commit
3ffb02e51e
|
|
@ -841,4 +841,25 @@ public class Claim
|
||||||
|
|
||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getChunkStrings()
|
||||||
|
{
|
||||||
|
ArrayList<String> chunkStrings = new ArrayList<String>();
|
||||||
|
World world = this.getLesserBoundaryCorner().getWorld();
|
||||||
|
int smallX = this.getLesserBoundaryCorner().getBlockX() >> 4;
|
||||||
|
int smallZ = this.getLesserBoundaryCorner().getBlockZ() >> 4;
|
||||||
|
int largeX = this.getGreaterBoundaryCorner().getBlockX() >> 4;
|
||||||
|
int largeZ = this.getGreaterBoundaryCorner().getBlockZ() >> 4;
|
||||||
|
|
||||||
|
for(int x = smallX; x <= largeX; x++)
|
||||||
|
{
|
||||||
|
for(int z = smallZ; z <= largeZ; z++)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder(String.valueOf(x)).append(world.getName()).append(z);
|
||||||
|
chunkStrings.add(builder.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunkStrings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,15 +214,14 @@ public abstract class DataStore
|
||||||
|
|
||||||
//add it and mark it as added
|
//add it and mark it as added
|
||||||
this.claims.add(newClaim);
|
this.claims.add(newClaim);
|
||||||
ArrayList<Chunk> chunks = newClaim.getChunks();
|
ArrayList<String> chunkStrings = newClaim.getChunkStrings();
|
||||||
for(Chunk chunk : chunks)
|
for(String chunkString : chunkStrings)
|
||||||
{
|
{
|
||||||
String chunkID = this.getChunkString(chunk);
|
ArrayList<Claim> claimsInChunk = this.chunksToClaimsMap.get(chunkString);
|
||||||
ArrayList<Claim> claimsInChunk = this.chunksToClaimsMap.get(chunkID);
|
|
||||||
if(claimsInChunk == null)
|
if(claimsInChunk == null)
|
||||||
{
|
{
|
||||||
claimsInChunk = new ArrayList<Claim>();
|
claimsInChunk = new ArrayList<Claim>();
|
||||||
this.chunksToClaimsMap.put(chunkID, claimsInChunk);
|
this.chunksToClaimsMap.put(chunkString, claimsInChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
claimsInChunk.add(newClaim);
|
claimsInChunk.add(newClaim);
|
||||||
|
|
@ -377,11 +376,10 @@ public abstract class DataStore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Chunk> chunks = claim.getChunks();
|
ArrayList<String> chunkStrings = claim.getChunkStrings();
|
||||||
for(Chunk chunk : chunks)
|
for(String chunkString : chunkStrings)
|
||||||
{
|
{
|
||||||
String chunkID = this.getChunkString(chunk);
|
ArrayList<Claim> claimsInChunk = this.chunksToClaimsMap.get(chunkString);
|
||||||
ArrayList<Claim> claimsInChunk = this.chunksToClaimsMap.get(chunkID);
|
|
||||||
for(int j = 0; j < claimsInChunk.size(); j++)
|
for(int j = 0; j < claimsInChunk.size(); j++)
|
||||||
{
|
{
|
||||||
if(claimsInChunk.get(j).id.equals(claim.id))
|
if(claimsInChunk.get(j).id.equals(claim.id))
|
||||||
|
|
@ -423,7 +421,7 @@ public abstract class DataStore
|
||||||
if(cachedClaim != null && cachedClaim.inDataStore && cachedClaim.contains(location, ignoreHeight, true)) return cachedClaim;
|
if(cachedClaim != null && cachedClaim.inDataStore && cachedClaim.contains(location, ignoreHeight, true)) return cachedClaim;
|
||||||
|
|
||||||
//find a top level claim
|
//find a top level claim
|
||||||
String chunkID = this.getChunkString(location.getChunk());
|
String chunkID = this.getChunkString(location);
|
||||||
ArrayList<Claim> claimsInChunk = this.chunksToClaimsMap.get(chunkID);
|
ArrayList<Claim> claimsInChunk = this.chunksToClaimsMap.get(chunkID);
|
||||||
if(claimsInChunk == null) return null;
|
if(claimsInChunk == null) return null;
|
||||||
|
|
||||||
|
|
@ -448,9 +446,13 @@ public abstract class DataStore
|
||||||
}
|
}
|
||||||
|
|
||||||
//gets a unique, persistent identifier string for a chunk
|
//gets a unique, persistent identifier string for a chunk
|
||||||
private String getChunkString(Chunk chunk)
|
private String getChunkString(Location location)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder(chunk.getWorld().getName()).append(chunk.getX()).append(chunk.getZ());
|
StringBuilder builder = new StringBuilder(
|
||||||
|
String.valueOf(location.getBlockX() >> 4))
|
||||||
|
.append(location.getWorld().getName())
|
||||||
|
.append(location.getBlockZ() >> 4);
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user