From d2a6698c2648279c928d50a975e912b0ac511fbe Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sat, 23 Mar 2024 09:08:55 +1100 Subject: Feature [feature-requests:#1512]. Reduce calls to vsDraw.ElementColour. --- src/EditView.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/EditView.cxx b/src/EditView.cxx index 5c88080a1..7070bc60f 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -845,10 +845,13 @@ ColourRGBA SelectionBackground(const EditModel &model, const ViewStyle &vsDraw, if (!model.primarySelection) element = Element::SelectionSecondaryBack; if (!model.hasFocus) { - if ((inSelection == InSelection::inAdditional) && vsDraw.ElementColour(Element::SelectionInactiveAdditionalBack)) { - element = Element::SelectionInactiveAdditionalBack; - } else if (vsDraw.ElementColour(Element::SelectionInactiveBack)) { - element = Element::SelectionInactiveBack; + if (inSelection == InSelection::inAdditional) { + if (ColourOptional colour = vsDraw.ElementColour(Element::SelectionInactiveAdditionalBack)) { + return *colour; + } + } + if (ColourOptional colour = vsDraw.ElementColour(Element::SelectionInactiveBack)) { + return *colour; } } return vsDraw.ElementColour(element).value_or(colourBug); @@ -863,13 +866,12 @@ ColourOptional SelectionForeground(const EditModel &model, const ViewStyle &vsDr if (!model.primarySelection) // Secondary selection element = Element::SelectionSecondaryText; if (!model.hasFocus) { - if ((inSelection == InSelection::inAdditional) && vsDraw.ElementColour(Element::SelectionInactiveAdditionalText)) { - element = Element::SelectionInactiveAdditionalText; - } else if (vsDraw.ElementColour(Element::SelectionInactiveText)) { - element = Element::SelectionInactiveText; - } else { - return {}; + if (inSelection == InSelection::inAdditional) { + if (ColourOptional colour = vsDraw.ElementColour(Element::SelectionInactiveAdditionalText)) { + return colour; + } } + element = Element::SelectionInactiveText; } return vsDraw.ElementColour(element); } -- cgit v1.2.3