This commit is contained in:
Mario Pietsch 2024-05-02 11:46:48 +01:00 committed by GitHub
commit 0a6cf767b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 0 deletions

View File

@ -35,6 +35,19 @@ TagIndexer.prototype.rebuild = function() {
};
TagIndexer.prototype.update = function(updateDescriptor) {
var newTid = updateDescriptor.new.tiddler;
var oldTid = updateDescriptor.old.tiddler;
var noOldTid = oldTid === undefined;
// a) new tiddler has no tags && no old tiddler -> or
// b) new tiddler has no tags && old tiddler has no tags -> return early!
var a=((newTid && newTid.fields && newTid.fields.tags === undefined) && noOldTid),
b=((newTid && newTid.fields && newTid.fields.tags === undefined) && (oldTid && oldTid.fields && oldTid.fields.tags === undefined));
if( a || b ) {
return; // early
}
$tw.utils.each(this.subIndexers,function(subIndexer) {
subIndexer.update(updateDescriptor);
});
@ -56,6 +69,9 @@ TagSubIndexer.prototype.addIndexMethod = function() {
TagSubIndexer.prototype.rebuild = function() {
var self = this;
// Hashmap by tag of array of {isSorted:, titles:[]}
const t0 = $tw.utils.timer();
this.index = Object.create(null);
// Add all the tags
this.indexer.wiki[this.iteratorMethod](function(tiddler,title) {
@ -67,6 +83,9 @@ TagSubIndexer.prototype.rebuild = function() {
}
});
});
console.log("--------------- ", $tw.utils.timer(t0), this.iteratorMethod);
};
TagSubIndexer.prototype.update = function(updateDescriptor) {