From b4399ffbb402943e1972a9ed04b3ddb3fa6c6cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 2 Feb 2016 23:10:43 +0100 Subject: Improve large file support Disable absolute line numbers for large files (currently anything bigger than 32MiB). This speeds up moving around with for example nn% since no new lines need to be calculated. Of course movements like :nn will be unaffected. The optimizations can be disabled by explicitly enabling absolute line numbers as in :set number --- vis.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 4c5124a..32deb80 100644 --- a/vis.c +++ b/vis.c @@ -43,6 +43,9 @@ #include "util.h" #include "vis-core.h" +/* enable large file optimization for files larger than: */ +#define LARGE_FILE (1 << 25) + static Macro *macro_get(Vis *vis, enum VisMacro m); static void macro_replay(Vis *vis, const Macro *macro); @@ -180,6 +183,14 @@ Win *window_new_file(Vis *vis, File *file) { } file->refcount++; view_tabwidth_set(win->view, vis->tabwidth); + + if (text_size(file->text) > LARGE_FILE) { + enum UiOption opt = view_options_get(win->view); + opt |= UI_OPTION_LARGE_FILE; + opt &= ~UI_OPTION_LINE_NUMBERS_ABSOLUTE; + view_options_set(win->view, opt); + } + if (vis->windows) vis->windows->prev = win; win->next = vis->windows; -- cgit v1.2.3