1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-17 15:24:50 +00:00

Precompile the filters for performance

This commit is contained in:
jeremy@jermolene.com 2021-11-04 16:43:06 +00:00
parent 9e41d410ee
commit b47a3ab585

View File

@ -15,13 +15,17 @@ Export our filter prefix function
exports.cascade = function(operationSubFunction,options) {
return function(results,source,widget) {
if(results.length !== 0) {
var filterList = operationSubFunction(source,widget);
var filterList = operationSubFunction(source,widget),
filterFnList = [];
var inputResults = results.toArray();
results.clear();
$tw.utils.each(inputResults,function(title) {
var result = ""; // If no filter matches, we return an empty string
$tw.utils.each(filterList,function(filter) {
var output = options.wiki.filterTiddlers(filter,{
$tw.utils.each(filterList,function(filter,index) {
if(!filterFnList[index]) {
filterFnList[index] = options.wiki.compileFilter(filter);
}
var output = filterFnList[index](options.wiki.makeTiddlerIterator([title]),{
getVariable: function(name) {
switch(name) {
case "currentTiddler":
@ -32,7 +36,7 @@ exports.cascade = function(operationSubFunction,options) {
return widget.getVariable(name);
}
}
},options.wiki.makeTiddlerIterator([title]));
});
if(output.length !== 0) {
result = output[0];
return false;