mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 14:41:23 +02:00
Mutate newDirtyPaths instead of creating a new array every iteration (#2559)
* Mutate newDirtyPaths instead of creating a new array every iteration * Switch to map + Array.prototype.concat.apply to improve readability * Update editor.js
This commit is contained in:
committed by
Ian Storm Taylor
parent
0edcc89692
commit
6672f553e9
@@ -100,14 +100,14 @@ class Editor {
|
||||
|
||||
// Get the paths of the affected nodes, and mark them as dirty.
|
||||
const newDirtyPaths = getDirtyPaths(operation)
|
||||
const dirty = this.tmp.dirty.reduce((memo, path) => {
|
||||
|
||||
const dirty = this.tmp.dirty.map(path => {
|
||||
path = PathUtils.create(path)
|
||||
const transformed = PathUtils.transform(path, operation)
|
||||
memo = memo.concat(transformed.toArray())
|
||||
return memo
|
||||
}, newDirtyPaths)
|
||||
return transformed.toArray()
|
||||
})
|
||||
|
||||
this.tmp.dirty = dirty
|
||||
this.tmp.dirty = Array.prototype.concat.apply(newDirtyPaths, dirty)
|
||||
|
||||
// If we're not already, queue the flushing process on the next tick.
|
||||
if (!this.tmp.flushing) {
|
||||
|
Reference in New Issue
Block a user