mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
faster implementation of ancestors
This commit is contained in:
parent
9ede77aead
commit
e2490f9975
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const Expression = require('./expression');
|
const Expression = require('./expression');
|
||||||
const NoteSet = require('../note_set');
|
const NoteSet = require('../note_set');
|
||||||
|
const noteCache = require('../../note_cache/note_cache');
|
||||||
|
|
||||||
class DescendantOfExp extends Expression {
|
class DescendantOfExp extends Expression {
|
||||||
constructor(subExpression) {
|
constructor(subExpression) {
|
||||||
@ -11,19 +12,16 @@ class DescendantOfExp extends Expression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
execute(inputNoteSet, searchContext) {
|
execute(inputNoteSet, searchContext) {
|
||||||
const resNoteSet = new NoteSet();
|
const subInputNoteSet = new NoteSet(Object.values(noteCache.notes));
|
||||||
|
|
||||||
for (const note of inputNoteSet.notes) {
|
|
||||||
const subInputNoteSet = new NoteSet(note.ancestors);
|
|
||||||
|
|
||||||
const subResNoteSet = this.subExpression.execute(subInputNoteSet, searchContext);
|
const subResNoteSet = this.subExpression.execute(subInputNoteSet, searchContext);
|
||||||
|
|
||||||
if (subResNoteSet.notes.length > 0) {
|
const subTreeNoteSet = new NoteSet();
|
||||||
resNoteSet.add(note);
|
|
||||||
}
|
for (const note of subResNoteSet.notes) {
|
||||||
|
subTreeNoteSet.addAll(note.subtreeNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resNoteSet;
|
return inputNoteSet.intersection(subTreeNoteSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user