1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-24 22:33:16 +00:00

removed conditional from iterator

I'd really like to see a profiler run against the two to see the
performance impact of one over the other
This commit is contained in:
Tobias Beer 2015-01-27 01:17:14 +01:00
parent c3cbbc3f66
commit a88ead9c0f

View File

@ -19,21 +19,31 @@ Export our filter function
exports.each = function(source,operator,options) { exports.each = function(source,operator,options) {
var results = [], var results = [],
values = {}, values = {},
list = "list" === operator.suffix; field = operator.operand || "title",
source(function(tiddler,title) { add = function(v) {
if(tiddler) { if(!$tw.utils.hop(values,v)) {
var field = operator.operand || "title", values[v] = true;
items = list ? results.push(v);
options.wiki.getTiddlerList(title,field) : }
[ "title" === field ? title : tiddler.getFieldString(operator.operand)]; };
$tw.utils.each(items,function(value){ if("list" !== operator.suffix) {
if(!$tw.utils.hop(values,value)) { source(function(tiddler,title) {
values[value] = true; if(tiddler) {
results.push(list ? value : title); add("title" === field ? title : tiddler.getFieldString(operator.operand));
} }
}); });
} } else {
}); source(function(tiddler,title) {
if(tiddler) {
$tw.utils.each(
options.wiki.getTiddlerList(title,field),
function(value) {
add(value);
}
);
}
});
}
return results; return results;
}; };