From 04a64e6e29798f61005a898f720d0a50decfe45b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 22 Jan 2021 17:18:02 +1100 Subject: [PATCH] Fix performance issue in show-matching highlighter on big buffers Stop searching for the matching character when getting out of view instead of going until the buffer edge. --- src/highlighters.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index 47278cd0..c3b996a8 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1203,7 +1203,7 @@ void show_matching_char(HighlightContext context, DisplayBuffer& display_buffer, { const Codepoint opening = *match; const Codepoint closing = *(match+1); - while (it != buffer.end()) + while (it.base().coord() <= range.end) { if (*it == opening) ++level; @@ -1230,7 +1230,7 @@ void show_matching_char(HighlightContext context, DisplayBuffer& display_buffer, false, apply_face(face)); break; } - if (it == buffer.begin()) + if (it.base().coord() <= range.begin) break; --it; }