mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Added caching strategy when (deep) comparing decks
Deck model comparison may be triggered a certain number of times, and the new deep-comparison on each part may slow down performance in deck editor. Therefore, a caching strategy has been integrated to avoid comparing the same objects multiple times.
This commit is contained in:
@@ -241,10 +241,14 @@ public class DeckController<T extends DeckBase> {
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean isInSyncCacheResult = null;
|
||||
private T syncModelCache = null;
|
||||
private boolean isModelInSyncWithFolder() {
|
||||
if (model.getName().isEmpty()) {
|
||||
if (syncModelCache != null && model == syncModelCache)
|
||||
return isInSyncCacheResult;
|
||||
|
||||
if (model.getName().isEmpty())
|
||||
return true;
|
||||
}
|
||||
|
||||
final T modelStored = currentFolder.get(model.getName());
|
||||
// checks presence in dictionary only.
|
||||
@@ -254,8 +258,9 @@ public class DeckController<T extends DeckBase> {
|
||||
if (modelStored == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return modelStored.equals(model);
|
||||
syncModelCache = model;
|
||||
isInSyncCacheResult = modelStored.equals(model);
|
||||
return isInSyncCacheResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user