Skip to content

ShadowPagingRegion: improve concurrency #761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: MC_1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,29 @@ public boolean cubeExists(CubePos pos) throws IOException {
public NBTTagCompound readColumn(ChunkPos pos) throws IOException {
//we use a true here in order to force creation and caching of the new region, thus avoiding an expensive Files.exists() check for every cube/column (which
// is really expensive on windows)
Optional<ByteBuffer> data = this.save.load(new EntryLocation2D(pos.x, pos.z), true);
return data.isPresent()
? CompressedStreamTools.readCompressed(new ByteArrayInputStream(data.get().array())) //decompress and parse NBT
: null; //column doesn't exist
Optional<ByteBuffer> optionalData = this.save.load(new EntryLocation2D(pos.x, pos.z), true);
if (!optionalData.isPresent()) { //column doesn't exist
return null;
}

//decompress and parse NBT
ByteBuffer data = optionalData.get();
return CompressedStreamTools.readCompressed(
new ByteArrayInputStream(data.array(), data.arrayOffset() + data.position(), data.remaining()));
}

@Override
public NBTTagCompound readCube(CubePos pos) throws IOException {
//see comment in readColumn
Optional<ByteBuffer> data = this.save.load(new EntryLocation3D(pos.getX(), pos.getY(), pos.getZ()), true);
return data.isPresent()
? CompressedStreamTools.readCompressed(new ByteArrayInputStream(data.get().array())) //decompress and parse NBT
: null; //cube doesn't exist
Optional<ByteBuffer> optionalData = this.save.load(new EntryLocation3D(pos.getX(), pos.getY(), pos.getZ()), true);
if (!optionalData.isPresent()) { //cube doesn't exist
return null;
}

//decompress and parse NBT
ByteBuffer data = optionalData.get();
return CompressedStreamTools.readCompressed(
new ByteArrayInputStream(data.array(), data.arrayOffset() + data.position(), data.remaining()));
}

@Override
Expand Down
Loading