geforkt von Mirrors/FastAsyncWorldEdit
Fix performance issues getting next file ids (#1027)
* Greetly optimize disk history * Greetly optimize disk cfi changeset * Remove wildcard import. * Improve performance fix * Improved performance fix
Dieser Commit ist enthalten in:
Ursprung
ae647dadfb
Commit
e4331844ac
@ -12,17 +12,26 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CFIChangeSet extends AbstractChangeSet {
|
||||
|
||||
private static final Map<UUID, Map<String, Integer>> NEXT_INDEX = new ConcurrentHashMap<>();
|
||||
|
||||
private final File file;
|
||||
|
||||
public CFIChangeSet(HeightMapMCAGenerator hmmg, UUID uuid) throws IOException {
|
||||
super(hmmg);
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + uuid + File.separator + "CFI" + File.separator + hmmg.getId());
|
||||
int max = MainUtil.getMaxFileId(folder);
|
||||
final String hmmgId = hmmg.getId();
|
||||
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + uuid + File.separator + "CFI" + File.separator + hmmgId);
|
||||
|
||||
final int max = NEXT_INDEX.computeIfAbsent(uuid, _uuid -> new HashMap<>())
|
||||
.compute(hmmgId, (_hmmgId, id) -> (id == null ? MainUtil.getMaxFileId(folder) : id) + 1) - 1;
|
||||
|
||||
this.file = new File(folder, max + ".cfi");
|
||||
File parent = this.file.getParentFile();
|
||||
if (!parent.exists()) {
|
||||
|
@ -19,7 +19,9 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Store the change on disk
|
||||
@ -30,6 +32,8 @@ import java.util.UUID;
|
||||
*/
|
||||
public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
|
||||
private static final Map<String, Map<UUID, Integer>> NEXT_INDEX = new ConcurrentHashMap<>();
|
||||
|
||||
private UUID uuid;
|
||||
private File bdFile;
|
||||
private File bioFile;
|
||||
@ -67,8 +71,11 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
|
||||
private void init(UUID uuid, String worldName) {
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + worldName + File.separator + uuid);
|
||||
int max = MainUtil.getMaxFileId(folder);
|
||||
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + worldName + File.separator + uuid);
|
||||
|
||||
final int max = NEXT_INDEX.computeIfAbsent(worldName, _worldName -> new ConcurrentHashMap<>())
|
||||
.compute(uuid, (_uuid, id) -> (id == null ? MainUtil.getMaxFileId(folder) : id) + 1) - 1;
|
||||
|
||||
init(uuid, max);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren