Merge pull request #2888 from atom/bo-speedup-decoration-render

Index line-wise decorations by ids
This commit is contained in:
Ben Ogle 2014-07-09 14:11:55 -07:00
commit 4c33549371
3 changed files with 20 additions and 12 deletions

View File

@ -295,8 +295,8 @@ EditorComponent = React.createClass
else
continue if decorationParams.onlyEmpty
decorationsByScreenRow[screenRow] ?= []
decorationsByScreenRow[screenRow].push decorationParams
decorationsByScreenRow[screenRow] ?= {}
decorationsByScreenRow[screenRow][decoration.id] = decorationParams
decorationsByScreenRow

View File

@ -154,7 +154,7 @@ GutterComponent = React.createClass
classes = ''
if lineDecorations? and decorations = lineDecorations[screenRow]
for decoration in decorations
for id, decoration of decorations
if Decoration.isType(decoration, 'gutter')
classes += decoration.class + ' '
@ -186,12 +186,13 @@ GutterComponent = React.createClass
previousDecorations = @renderedDecorationsByLineNumberId[lineNumberId]
if previousDecorations?
for decoration in previousDecorations
node.classList.remove(decoration.class) if Decoration.isType(decoration, 'gutter') and not _.deepContains(decorations, decoration)
for id, decoration of previousDecorations
if Decoration.isType(decoration, 'gutter') and not @hasDecoration(decorations, decoration)
node.classList.remove(decoration.class)
if decorations?
for decoration in decorations
if Decoration.isType(decoration, 'gutter') and not _.deepContains(previousDecorations, decoration)
for id, decoration of decorations
if Decoration.isType(decoration, 'gutter') and not @hasDecoration(previousDecorations, decoration)
node.classList.add(decoration.class)
unless @screenRowsByLineNumberId[lineNumberId] is screenRow
@ -201,6 +202,9 @@ GutterComponent = React.createClass
@screenRowsByLineNumberId[lineNumberId] = screenRow
@lineNumberIdsByScreenRow[screenRow] = lineNumberId
hasDecoration: (decorations, decoration) ->
decorations? and decorations[decoration.id] == decoration
hasLineNumberNode: (lineNumberId) ->
@lineNumberNodesById.hasOwnProperty(lineNumberId)

View File

@ -135,7 +135,7 @@ LinesComponent = React.createClass
classes = ''
if decorations = lineDecorations[screenRow]
for decoration in decorations
for id, decoration of decorations
if Decoration.isType(decoration, 'line')
classes += decoration.class + ' '
classes += 'line'
@ -240,12 +240,13 @@ LinesComponent = React.createClass
previousDecorations = @renderedDecorationsByLineId[line.id]
if previousDecorations?
for decoration in previousDecorations
lineNode.classList.remove(decoration.class) if Decoration.isType(decoration, 'line') and not _.deepContains(decorations, decoration)
for id, decoration of previousDecorations
if Decoration.isType(decoration, 'line') and not @hasDecoration(decorations, decoration)
lineNode.classList.remove(decoration.class)
if decorations?
for decoration in decorations
if Decoration.isType(decoration, 'line') and not _.deepContains(previousDecorations, decoration)
for id, decoration of decorations
if Decoration.isType(decoration, 'line') and not @hasDecoration(previousDecorations, decoration)
lineNode.classList.add(decoration.class)
lineNode.style.width = lineWidth + 'px' if updateWidth
@ -256,6 +257,9 @@ LinesComponent = React.createClass
@screenRowsByLineId[line.id] = screenRow
@lineIdsByScreenRow[screenRow] = line.id
hasDecoration: (decorations, decoration) ->
decorations? and decorations[decoration.id] == decoration
lineNodeForScreenRow: (screenRow) ->
@lineNodesByLineId[@lineIdsByScreenRow[screenRow]]