8
0
Pārlūkot izejas kodu

Performance optimization. Cache all the things.

Piotrek Koszuliński 5 gadi atpakaļ
vecāks
revīzija
adb237b10e
1 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  1. 6 3
      packages/ckeditor5-engine/src/model/treewalker.js

+ 6 - 3
packages/ckeditor5-engine/src/model/treewalker.js

@@ -225,7 +225,9 @@ export default class TreeWalker {
 			return { done: true };
 		}
 
-		const node = position.textNode ? position.textNode : position.nodeAfter;
+		// Get node just after the current position.
+		const textNodeAtPosition = position.textNode;
+		const node = textNodeAtPosition ? textNodeAtPosition : position.nodeAfter;
 
 		if ( node instanceof Element ) {
 			if ( !this.shallow ) {
@@ -299,8 +301,9 @@ export default class TreeWalker {
 			return { done: true };
 		}
 
-		// Get node just before current position
-		const node = position.textNode ? position.textNode : position.nodeBefore;
+		// Get node just before the current position.
+		const textNodeAtPosition = position.textNode;
+		const node = textNodeAtPosition ? textNodeAtPosition : position.nodeBefore;
 
 		if ( node instanceof Element ) {
 			position.offset--;