summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-09-24 13:55:06 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-09-24 13:55:06 +0100
commit12ef466f3a5dc97f9358e35eb4cfa5e16458afa9 (patch)
tree1d4772e2cc967a0bf8f6f75bea82dcfd0c626cb2 /src
parente601bd5fe8cc6525b45cd243462cd093281843d7 (diff)
Avoid redundant calls to get_face in highlight_selections
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index 8dd420e1..052ff657 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -822,7 +822,13 @@ void highlight_selections(const Context& context, HighlightFlags flags, DisplayB
{
if (flags != HighlightFlags::Highlight)
return;
+
const auto& buffer = context.buffer();
+ const Face primary_face = get_face("PrimarySelection");
+ const Face secondary_face = get_face("SecondarySelection");
+ 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)
{
auto& sel = context.selections()[i];
@@ -831,17 +837,15 @@ void highlight_selections(const Context& context, HighlightFlags flags, DisplayB
ByteCoord end = forward ? (ByteCoord)sel.cursor() : buffer.char_next(sel.anchor());
const bool primary = (i == context.selections().main_index());
- Face sel_face = get_face(primary ? "PrimarySelection" : "SecondarySelection");
highlight_range(display_buffer, begin, end, false,
- apply_face(sel_face));
+ apply_face(primary ? primary_face : secondary_face));
}
for (size_t i = 0; i < context.selections().size(); ++i)
{
auto& sel = context.selections()[i];
const bool primary = (i == context.selections().main_index());
- Face cur_face = get_face(primary ? "PrimaryCursor" : "SecondaryCursor");
highlight_range(display_buffer, sel.cursor(), buffer.char_next(sel.cursor()), false,
- apply_face(cur_face));
+ apply_face(primary ? primary_cursor_face : secondary_cursor_face));
}
}