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

Proposed by MC Return
Status: Merged
Approved by: Ɓukasz Zemczak
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 (community) continuous-integration Needs Fixing
Daniel van Vugt Approve
Sam Spilsbury Approve
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.
Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
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
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

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