mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Optimise the all filter operator
Seems like quite a decent optimisation.
This commit is contained in:
parent
21b2d6fdc7
commit
f6bd3b8c37
@ -33,6 +33,17 @@ exports.all = function(source,operator,options) {
|
|||||||
// Cycle through the suboperators accumulating their results
|
// Cycle through the suboperators accumulating their results
|
||||||
var results = [],
|
var results = [],
|
||||||
subops = operator.operand.split("+");
|
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++) {
|
for(var t=0; t<subops.length; t++) {
|
||||||
var subop = allFilterOperators[subops[t]];
|
var subop = allFilterOperators[subops[t]];
|
||||||
if(subop) {
|
if(subop) {
|
||||||
|
Loading…
Reference in New Issue
Block a user