Improve performance of various commands/actions

- Add chunk preloading to RegionVisitor if supplied with a suitable Extent
 - Where extents are used in masks, set EditSession as the extent as they are otherwise initialised with WorldWrapper that is very slow
 - Fixes #1073
This commit is contained in:
dordsor21
2021-07-24 15:47:22 +01:00
parent f2ee2248e0
commit 3b4beba7d6
10 changed files with 232 additions and 32 deletions

View File

@ -549,7 +549,9 @@ public interface Extent extends InputExtent, OutputExtent {
* @return the number of blocks that matched the mask
*/
default int countBlocks(Region region, Mask searchMask) {
RegionVisitor visitor = new RegionVisitor(region, searchMask::test);
//FAWE start > use slightly more performant RegionVisitor
RegionVisitor visitor = new RegionVisitor(region, searchMask::test, this);
//FAWE end
Operations.completeBlindly(visitor);
return visitor.getAffected();
}
@ -648,7 +650,9 @@ public interface Extent extends InputExtent, OutputExtent {
BlockReplace replace = new BlockReplace(this, pattern);
RegionMaskingFilter filter = new RegionMaskingFilter(this, mask, replace);
RegionVisitor visitor = new RegionVisitor(region, filter);
//FAWE start > add extent to RegionVisitor to allow chunk preloading
RegionVisitor visitor = new RegionVisitor(region, filter, this);
//FAWE end
Operations.completeLegacy(visitor);
return visitor.getAffected();
}