1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Optimise the tag filter

Spending a bit more time with Chrome dev tools, and further to 254e1ca, this optimisation reduces the rendering time for the sample TOC from 1.9s to about 0.9s...
This commit is contained in:
Jermolene 2017-12-21 16:13:47 +00:00
parent 7e71fcfab8
commit e4b10d42f9

View File

@ -25,17 +25,18 @@ exports.tag = function(source,operator,options) {
});
} else {
// Old semantics:
var tiddlers = options.wiki.getTiddlersWithTag(operator.operand);
if(operator.prefix === "!") {
// Returns a copy of the input if operator.operand is missing
source(function(tiddler,title) {
if(tiddler && !tiddler.hasTag(operator.operand)) {
if(tiddlers.indexOf(title) === -1) {
results.push(title);
}
});
} else {
// Returns empty results if operator.operand is missing
source(function(tiddler,title) {
if(tiddler && tiddler.hasTag(operator.operand)) {
if(tiddlers.indexOf(title) !== -1) {
results.push(title);
}
});