Slight optimization: Pull reference to @lines[0] in loop into a variable

This commit is contained in:
Nathan Sobo
2012-03-12 19:47:12 -06:00
parent 8061248d58
commit f7b9cf42d7

View File

@@ -202,15 +202,17 @@ class Editor extends View
elementsToReplace = @lineCache[startRow...endRow]
@lineCache[startRow...endRow] = lineElements?.toArray() or []
lines = @lines[0]
if lineElements
fragment = document.createDocumentFragment()
lineElements.each -> fragment.appendChild(this)
if elementToInsertBefore
@lines[0].insertBefore(fragment, elementToInsertBefore)
lines.insertBefore(fragment, elementToInsertBefore)
else
@lines[0].appendChild(fragment)
lines.appendChild(fragment)
$(elementsToReplace).remove()
elementsToReplace.forEach (element) =>
lines.removeChild(element)
getLineElement: (row) ->
@lineCache[row]