# HG changeset patch # User feyu@google.com # Date 1556231440 25200 # Node ID c4a50e863ee2d66718161834d3f4d214f978a071 # Parent 4ad191041be2c05165098276a9453487633f2a1b 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. diff -r 4ad191041be2 -r c4a50e863ee2 hgext/histedit.py --- 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()