Replace some if statements with a switch statement
The switch case statement allows the compiler to optimize code. More specifically, if the values are densely packed, then the compiler may generate a jump table. The switch statement also looks cleaner. As for the if statements in adjustWorkArea(), they were overlooked by me after LayerSurfaceV1Interface::exclusiveEdge() had been introduced.
This commit is contained in:
parent
3805f212ec
commit
e5dd5b6a77
1 changed files with 9 additions and 7 deletions
|
@ -72,17 +72,19 @@ void LayerShellV1Integration::destroyClient(LayerSurfaceV1Interface *shellSurfac
|
||||||
|
|
||||||
static void adjustWorkArea(const LayerSurfaceV1Interface *shellSurface, QRect *workArea)
|
static void adjustWorkArea(const LayerSurfaceV1Interface *shellSurface, QRect *workArea)
|
||||||
{
|
{
|
||||||
if (shellSurface->exclusiveEdge() == Qt::LeftEdge) {
|
switch (shellSurface->exclusiveEdge()) {
|
||||||
|
case Qt::LeftEdge:
|
||||||
workArea->adjust(shellSurface->leftMargin() + shellSurface->exclusiveZone(), 0, 0, 0);
|
workArea->adjust(shellSurface->leftMargin() + shellSurface->exclusiveZone(), 0, 0, 0);
|
||||||
}
|
break;
|
||||||
if (shellSurface->exclusiveEdge() == Qt::RightEdge) {
|
case Qt::RightEdge:
|
||||||
workArea->adjust(0, 0, -shellSurface->rightMargin() - shellSurface->exclusiveZone(), 0);
|
workArea->adjust(0, 0, -shellSurface->rightMargin() - shellSurface->exclusiveZone(), 0);
|
||||||
}
|
break;
|
||||||
if (shellSurface->exclusiveEdge() == Qt::TopEdge) {
|
case Qt::TopEdge:
|
||||||
workArea->adjust(0, shellSurface->topMargin() + shellSurface->exclusiveZone(), 0, 0);
|
workArea->adjust(0, shellSurface->topMargin() + shellSurface->exclusiveZone(), 0, 0);
|
||||||
}
|
break;
|
||||||
if (shellSurface->exclusiveEdge() == Qt::BottomEdge) {
|
case Qt::BottomEdge:
|
||||||
workArea->adjust(0, 0, 0, -shellSurface->bottomMargin() - shellSurface->exclusiveZone());
|
workArea->adjust(0, 0, 0, -shellSurface->bottomMargin() - shellSurface->exclusiveZone());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue