Mercurial > hg-stable
changeset 42263:c4a50e863ee2
histedit: Speed up scrolling in patch view mode
Store patchcontents into the mode state, avoiding the expensive
call to ui for computing the patchcontents.
Before this change in large repos histedit patch view mode can
be very irresponsive.
author | feyu@google.com |
---|---|
date | Thu, 25 Apr 2019 15:30:40 -0700 |
parents | 4ad191041be2 |
children | ade02721d3fa |
files | hgext/histedit.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Thu May 02 16:43:34 2019 -0700 +++ b/hgext/histedit.py Thu Apr 25 15:30:40 2019 -0700 @@ -1079,6 +1079,8 @@ def changemode(state, mode): curmode, _ = state['mode'] state['mode'] = (mode, curmode) + if mode == MODE_PATCH: + state['modes'][MODE_PATCH]['patchcontents'] = patchcontents(state) def makeselection(state, pos): state['selected'] = pos @@ -1134,7 +1136,7 @@ if mode != MODE_PATCH: return mode_state = state['modes'][mode] - num_lines = len(patchcontents(state)) + num_lines = len(mode_state['patchcontents']) page_height = state['page_height'] unit = page_height if unit == 'page' else 1 num_pages = 1 + (num_lines - 1) / page_height @@ -1394,7 +1396,8 @@ def renderpatch(win, state): start = state['modes'][MODE_PATCH]['line_offset'] - renderstring(win, state, patchcontents(state)[start:], diffcolors=True) + content = state['modes'][MODE_PATCH]['patchcontents'] + renderstring(win, state, content[start:], diffcolors=True) def layout(mode): maxy, maxx = stdscr.getmaxyx()