Skip to content

Commit 44ead78

Browse files
perf(plugin-git): memoize commit log rows (#82)
1 parent 2411279 commit 44ead78

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

plugins/git/src/client/components/views/log-panel-view.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import type { Commit } from '../../../index'
44
import type { GraphRow } from '../../lib/commit-graph'
55
import type { GitRef } from '../../lib/refs'
6-
import { useEffect, useMemo, useRef } from 'react'
6+
import { memo, useEffect, useMemo, useRef } from 'react'
77
import { computeGraph } from '../../lib/commit-graph'
88
import { parseRefs } from '../../lib/refs'
99
import { cn } from '../../lib/utils'
@@ -165,7 +165,7 @@ function RefLabel({ refToken, color }: { refToken: GitRef, color: string }) {
165165
)
166166
}
167167

168-
function CommitRow({ commit, row, gutter, currentBranch, isHead, topStub, selected, onSelect }: {
168+
const CommitRow = memo(({ commit, row, gutter, currentBranch, isHead, topStub, selected, onSelect }: {
169169
commit: Commit
170170
row: GraphRow
171171
gutter: number
@@ -174,7 +174,7 @@ function CommitRow({ commit, row, gutter, currentBranch, isHead, topStub, select
174174
topStub: boolean
175175
selected: boolean
176176
onSelect?: (hash: string) => void
177-
}) {
177+
}) => {
178178
const refs = useMemo(() => parseRefs(commit.refs, currentBranch), [commit.refs, currentBranch])
179179
const hasCurrent = refs.some(r => r.kind === 'branch' && r.current)
180180

@@ -222,7 +222,7 @@ function CommitRow({ commit, row, gutter, currentBranch, isHead, topStub, select
222222
</button>
223223
</li>
224224
)
225-
}
225+
})
226226

227227
function WipRow({ col, color, gutter, changes }: {
228228
col: number

0 commit comments

Comments
 (0)