Further optimize line replacement

This commit is contained in:
Antonio Scandurra
2017-04-12 10:48:21 +02:00
parent a99237b33b
commit 2993f3c1ac

View File

@@ -2912,7 +2912,12 @@ class LinesComponent {
textNodesByScreenLineId
})
this.element.insertBefore(newScreenLineComponent.element, oldScreenLineComponent.element)
oldScreenLineComponent.destroy()
// Instead of calling destroy on the component here we can simply
// remove its associated element, thus skipping the
// lineNodesByScreenLineId bookkeeping. This is possible because
// lineNodesByScreenLineId has already been updated when creating the
// new screen line component.
oldScreenLineComponent.element.remove()
this.lineComponents[lineComponentIndex] = newScreenLineComponent
oldScreenLineIndex++