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:
parent
9e41d410ee
commit
b47a3ab585
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user