aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2024-03-23 09:08:55 +1100
committerZufu Liu <unknown>2024-03-23 09:08:55 +1100
commitd2a6698c2648279c928d50a975e912b0ac511fbe (patch)
tree53228806888acb63dc5126547c407b5b3e7c781b
parentd8b5fc5dd9542e011974803ae5bdc0190baed774 (diff)
downloadscintilla-mirror-d2a6698c2648279c928d50a975e912b0ac511fbe.tar.gz
Feature [feature-requests:#1512]. Reduce calls to vsDraw.ElementColour.
-rw-r--r--src/EditView.cxx22
1 files changed, 12 insertions, 10 deletions
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);
}