8
0
Quellcode durchsuchen

Performance optimization. Cache all the things.

Piotrek Koszuliński vor 5 Jahren
Ursprung
Commit
adb237b10e
1 geänderte Dateien mit 6 neuen und 3 gelöschten Zeilen
  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--;