mirror of
https://github.com/atom/atom.git
synced 2026-01-26 07:19:06 -05:00
Cache line number gutter properties during a single frame
These properties are somewhat expensive to compute. Since we need to perform 2 updates per frame to perform horizontal measurement, it's good to avoid computing the gutter properties twice since they aren't affected by horizontal measurements in any way.
This commit is contained in:
committed by
Antonio Scandurra
parent
38f51ce74d
commit
7196b05af7
@@ -107,6 +107,7 @@ class TextEditorComponent {
|
||||
etch.updateSync(this)
|
||||
|
||||
this.pendingAutoscroll = null
|
||||
this.currentFramelineNumberGutterProps = null
|
||||
}
|
||||
|
||||
render () {
|
||||
@@ -158,6 +159,10 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
renderLineNumberGutter () {
|
||||
if (this.currentFramelineNumberGutterProps) {
|
||||
return $(LineNumberGutterComponent, this.currentFramelineNumberGutterProps)
|
||||
}
|
||||
|
||||
const model = this.getModel()
|
||||
const maxLineNumberDigits = Math.max(2, model.getLineCount().toString().length)
|
||||
|
||||
@@ -181,13 +186,15 @@ class TextEditorComponent {
|
||||
|
||||
const rowsPerTile = this.getRowsPerTile()
|
||||
|
||||
return $(LineNumberGutterComponent, {
|
||||
this.currentFramelineNumberGutterProps = {
|
||||
height: this.getScrollHeight(),
|
||||
width: this.measurements.lineNumberGutterWidth,
|
||||
lineHeight: this.measurements.lineHeight,
|
||||
startRow, endRow, rowsPerTile, maxLineNumberDigits,
|
||||
bufferRows, softWrappedFlags, foldableFlags
|
||||
})
|
||||
}
|
||||
|
||||
return $(LineNumberGutterComponent, this.currentFramelineNumberGutterProps)
|
||||
} else {
|
||||
return $.div(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user