1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Optimise the all filter operator

Seems like quite a decent optimisation.
This commit is contained in:
Jermolene 2014-04-30 22:50:47 +01:00
parent 21b2d6fdc7
commit f6bd3b8c37

View File

@ -33,6 +33,17 @@ exports.all = function(source,operator,options) {
// Cycle through the suboperators accumulating their results
var results = [],
subops = operator.operand.split("+");
// Check for common optimisations
if(subops.length === 1 && subops[0] === "tiddlers") {
return options.wiki.each;
} else if(subops.length === 1 && subops[0] === "shadows") {
return options.wiki.eachShadow;
} else if(subops.length === 2 && subops[0] === "tiddlers" && subops[1] === "shadows") {
return options.wiki.eachTiddlerPlusShadows;
} else if(subops.length === 2 && subops[0] === "shadows" && subops[1] === "tiddlers") {
return options.wiki.eachShadowPlusTiddlers;
}
// Do it the hard way
for(var t=0; t<subops.length; t++) {
var subop = allFilterOperators[subops[t]];
if(subop) {