From a09b094f2b062340c12d82ff6eef541133e4cd11 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 27 Jul 2016 09:03:01 +0100 Subject: [PATCH] Avoid repeated calls to context.selections() in highlight_selections --- src/highlighters.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index e60427b4..a8758458 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -850,21 +850,22 @@ void highlight_selections(const Context& context, HighlightFlags flags, DisplayB const Face primary_cursor_face = get_face("PrimaryCursor"); const Face secondary_cursor_face = get_face("SecondaryCursor"); - for (size_t i = 0; i < context.selections().size(); ++i) + const auto& selections = context.selections(); + for (size_t i = 0; i < selections.size(); ++i) { - auto& sel = context.selections()[i]; + auto& sel = selections[i]; const bool forward = sel.anchor() <= sel.cursor(); ByteCoord begin = forward ? sel.anchor() : buffer.char_next(sel.cursor()); ByteCoord end = forward ? (ByteCoord)sel.cursor() : buffer.char_next(sel.anchor()); - const bool primary = (i == context.selections().main_index()); + const bool primary = (i == selections.main_index()); highlight_range(display_buffer, begin, end, false, apply_face(primary ? primary_face : secondary_face)); } - for (size_t i = 0; i < context.selections().size(); ++i) + for (size_t i = 0; i < selections.size(); ++i) { - auto& sel = context.selections()[i]; - const bool primary = (i == context.selections().main_index()); + auto& sel = selections[i]; + const bool primary = (i == selections.main_index()); highlight_range(display_buffer, sel.cursor(), buffer.char_next(sel.cursor()), false, apply_face(primary ? primary_cursor_face : secondary_cursor_face)); }