1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-12-03 07:18:06 +00:00

Performance optimisations

In some situations, I’m seeing x2.5 speedups with these optimisations

Starts fixing #1864
This commit is contained in:
Jermolene
2015-07-05 19:47:44 +01:00
parent a86cfe2663
commit c6e48ebc2d
5 changed files with 54 additions and 39 deletions

View File

@@ -621,18 +621,20 @@ exports.getTiddlerData = function(titleOrTiddler,defaultData) {
tiddler = this.getTiddler(tiddler);
}
if(tiddler && tiddler.fields.text) {
switch(tiddler.fields.type) {
case "application/json":
// JSON tiddler
try {
data = JSON.parse(tiddler.fields.text);
} catch(ex) {
return defaultData;
}
return data;
case "application/x-tiddler-dictionary":
return $tw.utils.parseFields(tiddler.fields.text);
}
return this.getCacheForTiddler(tiddler.fields.title,"data",function() {
switch(tiddler.fields.type) {
case "application/json":
// JSON tiddler
try {
data = JSON.parse(tiddler.fields.text);
} catch(ex) {
return defaultData;
}
return data;
case "application/x-tiddler-dictionary":
return $tw.utils.parseFields(tiddler.fields.text);
}
});
}
return defaultData;
};