From cc9a8574416d803adf5fd645725b94e5db1b9ec5 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Mon, 24 Feb 2025 20:30:48 +0100 Subject: [PATCH] slightly optimize TreeWalker and integration process --- src/structs/Item.js | 3 +-- src/types/YXmlFragment.js | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/structs/Item.js b/src/structs/Item.js index 1b7ba939..2d2b1bb9 100644 --- a/src/structs/Item.js +++ b/src/structs/Item.js @@ -393,8 +393,7 @@ export class Item extends AbstractStruct { if (this.left && this.left.constructor === Item) { this.parent = this.left.parent this.parentSub = this.left.parentSub - } - if (this.right && this.right.constructor === Item) { + } else if (this.right && this.right.constructor === Item) { this.parent = this.right.parent this.parentSub = this.right.parentSub } diff --git a/src/types/YXmlFragment.js b/src/types/YXmlFragment.js index 2c0e9c5b..544a18ce 100644 --- a/src/types/YXmlFragment.js +++ b/src/types/YXmlFragment.js @@ -96,8 +96,12 @@ export class YXmlTreeWalker { } else { // walk right or up in the tree while (n !== null) { - if (n.right !== null) { - n = n.right + /** + * @type {Item | null} + */ + const nxt = n.next + if (nxt !== null) { + n = nxt break } else if (n.parent === this._root) { n = null