compression speed improvements
This commit is contained in:
parent
a013bf69b1
commit
36d7d767dd
|
@ -16,7 +16,6 @@ public class EPKCompiler {
|
|||
|
||||
public EPKCompiler(String name) {
|
||||
try {
|
||||
d = new Deflater(9);
|
||||
os = new DataOutputStream(osb);
|
||||
os.write("EAGPKG!!".getBytes(Charset.forName("UTF-8")));
|
||||
os.writeUTF("\n\n # eaglercraft package file - " + name + "\n # eagler eagler eagler eagler eagler eagler eagler\n\n");
|
||||
|
|
|
@ -89,7 +89,7 @@ public class VFSChunkLoader implements IChunkLoader {
|
|||
try {
|
||||
NBTTagCompound chunkFileSave = new NBTTagCompound();
|
||||
chunkFileSave.setCompoundTag("Level", chunkFile);
|
||||
save = CompressedStreamTools.compress(chunkFileSave);
|
||||
save = CompressedStreamTools.compressChunk(chunkFileSave);
|
||||
}catch(IOException e) {
|
||||
System.err.println("Corrupted chunk could not be serialized: [" + var2.xPosition + ", " + var2.zPosition + "]");
|
||||
return;
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.jcraft.jzlib.Deflater;
|
||||
import com.jcraft.jzlib.GZIPInputStream;
|
||||
import com.jcraft.jzlib.GZIPOutputStream;
|
||||
|
||||
|
@ -73,6 +74,19 @@ public class CompressedStreamTools {
|
|||
return var1.toByteArray();
|
||||
}
|
||||
|
||||
public static byte[] compressChunk(NBTTagCompound par0NBTTagCompound) throws IOException {
|
||||
ByteArrayOutputStream var1 = new ByteArrayOutputStream();
|
||||
DataOutputStream var2 = new DataOutputStream(new GZIPOutputStream(var1, new Deflater(2, 15+16), 2048, true));
|
||||
|
||||
try {
|
||||
write(par0NBTTagCompound, var2);
|
||||
} finally {
|
||||
var2.close();
|
||||
}
|
||||
|
||||
return var1.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from a CompressedStream.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user