9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 11:39:07 +00:00

Faster Interpolatin

This commit is contained in:
Daniel Mills
2021-08-03 18:03:27 -04:00
parent 36d3849118
commit 672c39e58d
9 changed files with 149 additions and 75 deletions

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.util.io;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.math.M;
import java.io.File;
@@ -48,10 +49,6 @@ public class FolderWatcher extends FileWatcher {
}
}
if (watchers == null) {
System.out.print("wtf");
}
for (File i : watchers.k()) {
if (!i.exists()) {
watchers.remove(i);
@@ -71,13 +68,13 @@ public class FolderWatcher extends FileWatcher {
KMap<File, FolderWatcher> w = watchers.copy();
readProperties();
for (File i : w.k()) {
for (File i : w.keySet()) {
if (!watchers.containsKey(i)) {
deleted.add(i);
}
}
for (File i : watchers.k()) {
for (File i : watchers.keySet()) {
if (!w.containsKey(i)) {
created.add(i);
} else {
@@ -98,6 +95,34 @@ public class FolderWatcher extends FileWatcher {
return super.checkModified();
}
public boolean checkModifiedFast() {
if(watchers == null || watchers.isEmpty())
{
return checkModified();
}
changed.clear();
created.clear();
deleted.clear();
if (file.isDirectory()) {
for (File i : watchers.keySet()) {
FolderWatcher fw = watchers.get(i);
if (fw.checkModifiedFast()) {
changed.add(fw.file);
}
changed.addAll(fw.getChanged());
created.addAll(fw.getCreated());
deleted.addAll(fw.getDeleted());
}
return !changed.isEmpty() || !created.isEmpty() || !deleted.isEmpty();
}
return super.checkModified();
}
public KMap<File, FolderWatcher> getWatchers() {
return watchers;
}

View File

@@ -27,6 +27,7 @@ public class ReactiveFolder {
private final File folder;
private final Consumer3<KList<File>, KList<File>, KList<File>> hotload;
private FolderWatcher fw;
private int checkCycle = 0;
public ReactiveFolder(File folder, Consumer3<KList<File>, KList<File>, KList<File>> hotload) {
this.folder = folder;
@@ -39,10 +40,11 @@ public class ReactiveFolder {
fw = new FolderWatcher(folder);
}
public void check() {
public boolean check() {
checkCycle++;
boolean modified = false;
if (fw.checkModified()) {
if (checkCycle % 3 == 0 ? fw.checkModified() : fw.checkModifiedFast()) {
for (File i : fw.getCreated()) {
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json")) {
modified = true;
@@ -73,6 +75,6 @@ public class ReactiveFolder {
hotload.accept(fw.getCreated(), fw.getChanged(), fw.getDeleted());
}
fw.checkModified();
return fw.checkModified();
}
}