1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-13 18:53:59 +02:00

Deduplicate dirty paths for normalization. (#2916)

* Deduplicate dirty paths for normalization.

* Update editor.js
This commit is contained in:
themithy
2019-08-19 18:37:38 +02:00
committed by Ian Storm Taylor
parent 8ab49c04c4
commit ff831eba7d

View File

@@ -107,7 +107,20 @@ class Editor {
return transformed.toArray() return transformed.toArray()
}) })
this.tmp.dirty = Array.prototype.concat.apply(newDirtyPaths, dirty) const pathIndex = {}
const dirtyPaths = Array.prototype.concat.apply(newDirtyPaths, dirty)
this.tmp.dirty = []
// PERF: De-dupe the paths so we don't do extra normalization.
dirtyPaths.forEach(dirtyPath => {
const key = dirtyPath.join(',')
if (!pathIndex[key]) {
this.tmp.dirty.push(dirtyPath)
}
pathIndex[key] = true
})
// If we're not already, queue the flushing process on the next tick. // If we're not already, queue the flushing process on the next tick.
if (!this.tmp.flushing) { if (!this.tmp.flushing) {