summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-07-27 09:03:01 +0100
committerMaxime Coste <frrrwww@gmail.com>2016-07-27 09:03:01 +0100
commita09b094f2b062340c12d82ff6eef541133e4cd11 (patch)
tree33bd3711f104bd559223cf7a8fc48ab44a0484bc /src
parent0d2c5072b083a893843e4fa87f9f702979069e14 (diff)
Avoid repeated calls to context.selections() in highlight_selections
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc13
1 files 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));
}