Browse Source

Remove redundant slice and move it to return statements.

Maciej Gołaszewski 5 years ago
parent
commit
7e7e4b77d1
1 changed files with 5 additions and 5 deletions
  1. 5 5
      packages/ckeditor5-engine/src/model/differ.js

+ 5 - 5
packages/ckeditor5-engine/src/model/differ.js

@@ -476,7 +476,7 @@ export default class Differ {
 					i++;
 					j++;
 				} else if ( action === 'x' ) {
-					// Swap action - similar to 'equal'
+					// Swap action - similar to 'equal'.
 					diffSet.push( this._getRefreshDiff( element, i, elementChildren[ i ].name ) );
 
 					i++;
@@ -561,13 +561,13 @@ export default class Differ {
 		this._changeCount = 0;
 
 		// Cache changes.
-		this._cachedChangesWithGraveyard = diffSet.slice();
-		this._cachedChanges = diffSet.slice().filter( _changesInGraveyardFilter );
+		this._cachedChangesWithGraveyard = diffSet;
+		this._cachedChanges = diffSet.filter( _changesInGraveyardFilter );
 
 		if ( options.includeChangesInGraveyard ) {
-			return this._cachedChangesWithGraveyard;
+			return this._cachedChangesWithGraveyard.slice();
 		} else {
-			return this._cachedChanges;
+			return this._cachedChanges.slice();
 		}
 	}