More performance optimizations

This commit is contained in:
crschnick 2023-10-16 10:53:32 +00:00
parent c80a31bffe
commit 7995d95b8d
5 changed files with 27 additions and 11 deletions

View file

@ -34,7 +34,9 @@ public class StoreEntryListComp extends SimpleComp {
var initialCount = 1;
var showIntro = Bindings.createBooleanBinding(
() -> {
return initialCount == StoreViewState.get().getAllEntries().size();
var all = StoreViewState.get().getAllConnectionsCategory();
var connections = StoreViewState.get().getAllEntries().stream().filter(wrapper -> all.contains(wrapper.getEntry())).toList();
return initialCount == connections.size();
},
StoreViewState.get().getAllEntries());
var map = new LinkedHashMap<Comp<?>, ObservableValue<Boolean>>();

View file

@ -41,11 +41,6 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
@Override
public CompStructure<VBox> createBase() {
var content = new ListBoxViewComp<>(section.getShownChildren(), section.getAllChildren(), (StoreSection e) -> {
return StoreSectionMiniComp.builder().section(e).augment(this.augment).build();
}).withLimit(100)
.hgrow();
var list = new ArrayList<Comp<?>>();
BooleanProperty expanded;
if (section.getWrapper() != null) {
@ -91,6 +86,19 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
expanded = new SimpleBooleanProperty(true);
}
// Optimization for large sections. If there are more than 20 children, only add the nodes to the scene if the
// section is actually expanded
var listSections = section.getWrapper() != null ? BindingsHelper.filteredContentBinding(
section.getShownChildren(),
storeSection -> section.getAllChildren().size() <= 20
|| expanded.get(),
expanded,
section.getAllChildren()) : section.getShownChildren();
var content = new ListBoxViewComp<>(listSections, section.getAllChildren(), (StoreSection e) -> {
return StoreSectionMiniComp.builder().section(e).augment(this.augment).build();
}).withLimit(100)
.hgrow();
list.add(new HorizontalComp(List.of(content))
.styleClass("content")
.apply(struc -> struc.get().setFillHeight(true))

View file

@ -560,6 +560,7 @@ public abstract class DataStorage {
public void deleteStoreEntry(@NonNull DataStoreEntry store) {
store.finalizeEntry();
this.storeEntries.remove(store);
getDisplayParent(store).ifPresent(p -> p.setChildrenCache(null));
this.listeners.forEach(l -> l.onStoreRemove(store));
refreshValidities(false);
saveAsync();

View file

@ -4,7 +4,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutorService;
public interface ProcessControl extends AutoCloseable {
@ -17,10 +16,6 @@ public interface ProcessControl extends AutoCloseable {
void resetData();
ExecutorService getStdoutReader();
ExecutorService getStderrReader();
String prepareTerminalOpen(String displayName) throws Exception;
void closeStdin() throws IOException;

10
dist/build.gradle vendored
View file

@ -36,6 +36,16 @@ task createChecksums(type: Checksum) {
}
}
}
clean {
doFirst {
// Fix clean failing when file is read-only
if (file("$distDir").exists()) {
file("$distDir").traverse { f -> if (f.exists() && f.isFile()) f.writable = true }
}
}
}
dist.finalizedBy(createChecksums)
apply from: 'base.gradle'