mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Use unsynchronized buffered OutputStream for history (#2127)
* Use unsychronized buffered OutputStream * Add note * Avoid synchronization on DataOutputStream#write
This commit is contained in:
parent
211e8034ff
commit
8a3052683e
@ -20,6 +20,13 @@ public class FaweOutputStream extends DataOutputStream {
|
||||
return parent;
|
||||
}
|
||||
|
||||
// overwritten to un-synchronized
|
||||
@Override
|
||||
public void write(final int b) throws IOException {
|
||||
out.write(b);
|
||||
written++;
|
||||
}
|
||||
|
||||
public void write(int b, int amount) throws IOException {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
write(b);
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
|
||||
import it.unimi.dsi.fastutil.io.FastBufferedOutputStream;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
@ -40,7 +41,6 @@ import javax.imageio.ImageIO;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -273,9 +273,12 @@ public class MainUtil {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: The returned stream is not thread safe.
|
||||
*/
|
||||
public static FaweOutputStream getCompressedOS(OutputStream os, int amount, int buffer) throws IOException {
|
||||
os.write((byte) 10 + amount);
|
||||
os = new BufferedOutputStream(os, buffer);
|
||||
os = new FastBufferedOutputStream(os, buffer);
|
||||
if (amount == 0) {
|
||||
return new FaweOutputStream(os);
|
||||
}
|
||||
@ -296,7 +299,7 @@ public class MainUtil {
|
||||
os = new LZ4BlockOutputStream(os, buffer, factory.highCompressor());
|
||||
}
|
||||
}
|
||||
os = new BufferedOutputStream(os, buffer);
|
||||
os = new FastBufferedOutputStream(os, buffer);
|
||||
return new FaweOutputStream(os);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user