Merge lp:~mc-return/compiz/compiz.merge-shiftswitcher-one-if-statement-is-enough into lp:compiz/0.9.9

Proposed by MC Return on 2012-11-01
Status: Merged
Approved by: Ɓukasz Zemczak on 2012-11-05
Approved revision: 3447
Merged at revision: 3450
Proposed branch: lp:~mc-return/compiz/compiz.merge-shiftswitcher-one-if-statement-is-enough
Merge into: lp:compiz/0.9.9
Diff against target: 27 lines (+2/-8)
1 file modified
plugins/shift/src/shift.cpp (+2/-8)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-shiftswitcher-one-if-statement-is-enough
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2012-11-05
Daniel van Vugt Approve on 2012-11-05
Sam Spilsbury 2012-11-01 Approve on 2012-11-01
Review via email: mp+132516@code.launchpad.net

Commit Message

Shift Switcher: Minor optimization: As we return in both cases one if statement is enough here (x2).

Description of the Change

Thanks for the suggestion, Daniel :) - you are right of course.

To post a comment you must log in.
Sam Spilsbury (smspillaz) :
review: Approve
Daniel van Vugt (vanvugt) wrote :

If the intention is optimization then De Morgan's law [1] suggests there's a more efficient way with fewer operations:
    if (!(textAvailable && optionGetWindowTitle ()))
[1] http://en.wikipedia.org/wiki/De_Morgan's_laws

However I think the syntax you have already is more readable.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/shift/src/shift.cpp'
2--- plugins/shift/src/shift.cpp 2012-10-24 09:33:31 +0000
3+++ plugins/shift/src/shift.cpp 2012-11-01 11:21:22 +0000
4@@ -139,10 +139,7 @@
5 void
6 ShiftScreen::renderWindowTitle ()
7 {
8- if (!textAvailable)
9- return;
10-
11- if (!optionGetWindowTitle ())
12+ if (!textAvailable || !optionGetWindowTitle ())
13 return;
14
15 CompText::Attrib tA;
16@@ -187,10 +184,7 @@
17 void
18 ShiftScreen::drawWindowTitle (const GLMatrix &transform)
19 {
20- if (!textAvailable)
21- return;
22-
23- if (!optionGetWindowTitle ())
24+ if (!textAvailable || !optionGetWindowTitle ())
25 return;
26
27 float width, height, border = 10.0f;

Subscribers

People subscribed via source and target branches