From f6bd3b8c37722afee4456d46f71f934abf230ae5 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 30 Apr 2014 22:50:47 +0100 Subject: [PATCH] Optimise the all filter operator Seems like quite a decent optimisation. --- core/modules/filters/all.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/modules/filters/all.js b/core/modules/filters/all.js index 12aab2b7b..ee31f4abb 100644 --- a/core/modules/filters/all.js +++ b/core/modules/filters/all.js @@ -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