Skip to content

Commit 77f9654

Browse files
committed
[GTK] Simplify _setBackground() and setForeground() in Control widget
The local variable "set" is always set to true in _setBackground() and is therefore redundant. This is because some widgets might have a default color, so it must always be set. For setForeground(), the initial value of the local variable is immediately overridden and can therefore be skipped as well.
1 parent 18d4990 commit 77f9654

File tree

1 file changed

+6
-11
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets

1 file changed

+6
-11
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,21 +5187,17 @@ private void _setBackground (Color color) {
51875187
if (color != null && color.isDisposed ()) {
51885188
error(SWT.ERROR_INVALID_ARGUMENT);
51895189
}
5190-
boolean set = false;
51915190
GdkRGBA rgba = null;
51925191
if (color != null) {
51935192
rgba = color.handle;
51945193
backgroundAlpha = color.getAlpha();
51955194
}
5196-
set = true;
5197-
if (set) {
5198-
if (color == null) {
5199-
state &= ~BACKGROUND;
5200-
} else {
5201-
state |= BACKGROUND;
5202-
}
5203-
setBackgroundGdkRGBA (rgba);
5195+
if (color == null) {
5196+
state &= ~BACKGROUND;
5197+
} else {
5198+
state |= BACKGROUND;
52045199
}
5200+
setBackgroundGdkRGBA (rgba);
52055201
redrawChildren ();
52065202
}
52075203

@@ -5539,8 +5535,7 @@ public void setForeground (Color color) {
55395535
if (color != null && color.isDisposed ()) {
55405536
error(SWT.ERROR_INVALID_ARGUMENT);
55415537
}
5542-
boolean set = false;
5543-
set = !getForeground().equals(color);
5538+
boolean set = !getForeground().equals(color);
55445539
if (set) {
55455540
if (color == null) {
55465541
state &= ~FOREGROUND;

0 commit comments

Comments
 (0)