1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-05 01:26:18 +00:00

Wire up the tag indexer properly

Improves rendering performance by a factor of 4, but we're still 5 times slower than the plain JS store
This commit is contained in:
Jeremy Ruston 2023-07-19 21:52:28 +01:00
parent 2d3027faab
commit 7fd2dd5a3e

View File

@ -81,8 +81,14 @@ $tw.Wiki = function(options) {
self.sqlFunctions.sqlLogTables();
}
var tagIndexer;
this.addIndexer = function(indexer,name) {
return;
switch(indexer.constructor.name) {
case "TagIndexer":
tagIndexer = new TagIndexer(this);
break;
}
};
function TagSubIndexer(indexer,iteratorMethod) {
@ -90,6 +96,13 @@ $tw.Wiki = function(options) {
this.iteratorMethod = iteratorMethod;
}
TagSubIndexer.prototype.addIndexMethod = function() {
var self = this;
this.indexer.wiki[this.iteratorMethod].byTag = function(tag) {
return self.lookup(tag).slice(0);
};
};
TagSubIndexer.prototype.lookup = function(tag) {
return self.sqlFunctions.sqlGetTiddlersWithTag(tag,this.iteratorMethod);
};
@ -102,10 +115,11 @@ $tw.Wiki = function(options) {
new TagSubIndexer(this,"eachTiddlerPlusShadows"),
new TagSubIndexer(this,"eachShadowPlusTiddlers")
];
$tw.utils.each(this.subIndexers,function(subIndexer) {
subIndexer.addIndexMethod();
});
}
var tagIndexer = new TagIndexer();
this.getIndexer = function(name) {
switch(name) {
case "TagIndexer":
@ -327,6 +341,10 @@ $tw.Wiki = function(options) {
this.clearCache(null);
this.clearGlobalCache();
};
if(this.addIndexersToWiki) {
this.addIndexersToWiki();
}
};
})();