agenericbob
New Member
- Jan 27, 2018
- 5
- 11
- 182
Maelion I read your Patreon posts recently and saw the work on the slow loading/saving. I debugged that myself previously and fixed it without needing to debloat the load/save files.
A big problem is that when displaying the screen with the saves, RPG maker loads all the entries for every entry, resulting in quadratic behavior, which really hurts with large numbers of saves (I'm up to 100 something as I like to save a lot due to lack of gallery). I put a cache in place that only reloads the list of saves if the cached list is older than 5 seconds:
This is a diff on www/js/rpg_manager.js, I'd attach the full file for those not knowing diff, but apparently .js files are not allowed. With this change the load/save menu opens pretty much instantly for me.
A big problem is that when displaying the screen with the saves, RPG maker loads all the entries for every entry, resulting in quadratic behavior, which really hurts with large numbers of saves (I'm up to 100 something as I like to save a lot due to lack of gallery). I put a cache in place that only reloads the list of saves if the cached list is older than 5 seconds:
Code:
diff --git a/Cyberslayers/www/js/rpg_managers.js b/Cyberslayers/www/js/rpg_managers.js
index 49f61a9..faf29e4 100644
--- a/Cyberslayers/www/js/rpg_managers.js
+++ b/Cyberslayers/www/js/rpg_managers.js
@@ -45,6 +45,9 @@ DataManager._globalId = 'RPGMV';
DataManager._lastAccessedId = 1;
DataManager._errorUrl = null;
+var $_global = null;
+var $_globalTime = 0;
+
DataManager._databaseFiles = [
{ name: '$dataActors', src: 'Actors.json' },
{ name: '$dataClasses', src: 'Classes.json' },
@@ -239,6 +242,8 @@ DataManager.setupEventTest = function() {
};
DataManager.loadGlobalInfo = function() {
+ if (Date.now() - $_globalTime < 5000)
+ return $_global;
var json;
try {
json = StorageManager.load(0);
@@ -253,6 +258,8 @@ DataManager.loadGlobalInfo = function() {
delete globalInfo[i];
}
}
+ $_global = globalInfo;
+ $_globalTime = Date.now();
return globalInfo;
} else {
return [];