From f46d732c9e0303b86f607fa8cccffdebaeaa9ad2 Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Mon, 14 Mar 2022 16:29:42 +0100 Subject: [PATCH] Other (engine): Improved `model.TreeWalker#next()` efficiency. --- packages/ckeditor5-engine/src/model/treewalker.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/ckeditor5-engine/src/model/treewalker.js b/packages/ckeditor5-engine/src/model/treewalker.js index 4ed3c1dd821..1e92acb818b 100644 --- a/packages/ckeditor5-engine/src/model/treewalker.js +++ b/packages/ckeditor5-engine/src/model/treewalker.js @@ -233,9 +233,8 @@ export default class TreeWalker { // Get node just after the current position. // Use a highly optimized version instead of checking the text node first and then getting the node after. See #6582. - const positionParent = position.parent; - const textNodeAtPosition = getTextNodeAtPosition( position, positionParent ); - const node = textNodeAtPosition ? textNodeAtPosition : getNodeAfterPosition( position, positionParent, textNodeAtPosition ); + const textNodeAtPosition = getTextNodeAtPosition( position, parent ); + const node = textNodeAtPosition ? textNodeAtPosition : getNodeAfterPosition( position, parent, textNodeAtPosition ); if ( node instanceof Element ) { if ( !this.shallow ) {