Merge lp:~mc-return/compiz/compiz.fix1030473-part2 into lp:compiz/0.9.8

Proposed by MC Return
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3315
Merged at revision: 3302
Proposed branch: lp:~mc-return/compiz/compiz.fix1030473-part2
Merge into: lp:compiz/0.9.8
Diff against target: 242 lines (+21/-21)
16 files modified
compizconfig/libcompizconfig/src/iniparser.c (+1/-1)
plugins/animation/src/extensionplugin.cpp (+3/-3)
plugins/colorfilter/src/colorfilter.cpp (+1/-1)
plugins/colorfilter/src/parser.cpp (+1/-1)
plugins/dbus/src/dbus.cpp (+1/-1)
plugins/decor/src/decor.cpp (+1/-1)
plugins/firepaint/src/firepaint.cpp (+2/-2)
plugins/grid/src/grid.cpp (+1/-1)
plugins/group/src/init.cpp (+2/-2)
plugins/opacify/src/opacify.cpp (+1/-1)
plugins/ring/src/ring.cpp (+1/-1)
plugins/scale/src/scale.cpp (+1/-1)
plugins/thumbnail/src/thumbnail.cpp (+1/-1)
plugins/wallpaper/src/wallpaper.cpp (+2/-2)
src/match.cpp (+1/-1)
src/screen.cpp (+1/-1)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.fix1030473-part2
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Sam Spilsbury Approve
Review via email: mp+117410@code.launchpad.net

Commit message

Fixed various problems described in bug 1030473.
Optimized performance and style following suggestions reported by cppcheck:

1. Used !xxxx.empty() instead of xxxx.size(), because it can be faster. xxxx.size() can take linear time while xxxx.empty() is guaranteed to take constant time.

2. Defensive programming: Reordered array-out-of-bound condition checks such as '(a[i] && i < 10)' to '(i < 10 && a[i])'. That way the array will not be accessed, because the index is checked first.

Description of the change

Fixes various problems described in bug 1030473.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

LGTM

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Looks good and passes basic testing.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'compizconfig/libcompizconfig/src/iniparser.c'
2--- compizconfig/libcompizconfig/src/iniparser.c 2007-08-24 13:03:28 +0000
3+++ compizconfig/libcompizconfig/src/iniparser.c 2012-07-31 13:52:21 +0000
4@@ -120,7 +120,7 @@
5 memset (l, 0, ASCIILINESZ + 1);
6 i = 0;
7
8- while (s[i] && i < ASCIILINESZ)
9+ while (i < ASCIILINESZ && s[i])
10 {
11 l[i] = (char) tolower ((int) s[i]);
12 i++;
13
14=== modified file 'plugins/animation/src/extensionplugin.cpp'
15--- plugins/animation/src/extensionplugin.cpp 2011-09-15 09:54:32 +0000
16+++ plugins/animation/src/extensionplugin.cpp 2012-07-31 13:52:21 +0000
17@@ -432,13 +432,13 @@
18 wEnd = wRestacked;
19 wOldAbove = wStart;
20 }
21- else if (clients[(unsigned)changeStart] ==
22- mLastClientList[(unsigned)changeEnd] && // lowered
23+ else if ((unsigned int)changeEnd < n - 1 &&
24+ clients[(unsigned)changeStart] ==
25+ mLastClientList[(unsigned)changeEnd]) // lowered
26 // We don't animate lowering if there is no
27 // window above this window, since this window needs
28 // to be drawn on such a "host" in animPaintWindow
29 // (at least for now).
30- (unsigned int)changeEnd < n - 1)
31 {
32 wRestacked = wChangeStart;
33 wStart = wRestacked;
34
35=== modified file 'plugins/colorfilter/src/colorfilter.cpp'
36--- plugins/colorfilter/src/colorfilter.cpp 2010-11-04 13:19:13 +0000
37+++ plugins/colorfilter/src/colorfilter.cpp 2012-07-31 13:52:21 +0000
38@@ -298,7 +298,7 @@
39 /* We are filtering a decoration */
40 if ((cfs->optionGetFilterDecorations () &&
41 isFiltered &&
42- cfs->filtersFunctions.size ()))
43+ !cfs->filtersFunctions.empty ()))
44 shouldFilter = true;
45
46 /* Check if filters have to be loaded and load them if so
47
48=== modified file 'plugins/colorfilter/src/parser.cpp'
49--- plugins/colorfilter/src/parser.cpp 2010-11-04 14:47:16 +0000
50+++ plugins/colorfilter/src/parser.cpp 2012-07-31 13:52:21 +0000
51@@ -435,7 +435,7 @@
52
53 if (temp == "fragment.texcoord[0]")
54 data->addFetchOp (arg1.c_str (), NULL, target);
55- else if (offsets.size ())
56+ else if (!offsets.empty ())
57 {
58 arg2 = programFindOffset (
59 offsets.begin (),
60
61=== modified file 'plugins/dbus/src/dbus.cpp'
62--- plugins/dbus/src/dbus.cpp 2012-06-24 09:00:27 +0000
63+++ plugins/dbus/src/dbus.cpp 2012-07-31 13:52:21 +0000
64@@ -1525,7 +1525,7 @@
65 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
66
67 /* root messages */
68- if (path.size () == 0)
69+ if (path.empty ())
70 {
71 #if GET_PLUGIN_METADATA_ENABLED
72 if (dbus_message_is_method_call (message,
73
74=== modified file 'plugins/decor/src/decor.cpp'
75--- plugins/decor/src/decor.cpp 2012-07-09 11:09:28 +0000
76+++ plugins/decor/src/decor.cpp 2012-07-31 13:52:21 +0000
77@@ -1327,7 +1327,7 @@
78 std::list <Decoration::Ptr>::iterator cit = mList.end ();
79 DECOR_WINDOW (w);
80
81- if (mList.size ())
82+ if (!mList.empty ())
83 {
84 const unsigned int typeMatch = (1 << 0);
85 const unsigned int stateMatch = (1 << 1);
86
87=== modified file 'plugins/firepaint/src/firepaint.cpp'
88--- plugins/firepaint/src/firepaint.cpp 2010-10-23 15:42:02 +0000
89+++ plugins/firepaint/src/firepaint.cpp 2012-07-31 13:52:21 +0000
90@@ -456,7 +456,7 @@
91 float size = 4;
92 float bg = (float) optionGetBgBrightness () / 100.0;
93
94- if (init && points.size ())
95+ if (init && !points.empty ())
96 {
97 ps.initParticles (optionGetNumParticles ());
98 init = false;
99@@ -480,7 +480,7 @@
100 if (!init)
101 ps.updateParticles (time);
102
103- if (points.size ())
104+ if (!points.empty ())
105 {
106 float max_new = MIN ((int) ps.particles.size (), (int) points.size () * 2) *
107 ((float) time / 50.0) *
108
109=== modified file 'plugins/grid/src/grid.cpp'
110--- plugins/grid/src/grid.cpp 2012-05-27 04:32:55 +0000
111+++ plugins/grid/src/grid.cpp 2012-07-31 13:52:21 +0000
112@@ -711,7 +711,7 @@
113
114 if (lastSlot != desiredSlot)
115 {
116- if (animations.size ())
117+ if (!animations.empty ())
118 /* Begin fading previous animation instance */
119 animations.at (animations.size () - 1).fadingOut = true;
120
121
122=== modified file 'plugins/group/src/init.cpp'
123--- plugins/group/src/init.cpp 2012-05-27 04:32:55 +0000
124+++ plugins/group/src/init.cpp 2012-07-31 13:52:21 +0000
125@@ -118,7 +118,7 @@
126 glowProperty->textureSize),
127 GL_RGBA, GL_UNSIGNED_BYTE);
128
129- if (optionGetGlow () && mGroups.size ())
130+ if (optionGetGlow () && !mGroups.empty ())
131 {
132 foreach (CompWindow *w, screen->windows ())
133 {
134@@ -228,7 +228,7 @@
135 mGrabState == GroupScreen::ScreenGrabTabDrag)
136 functionsMask |= (GL_PAINT_OUTPUT |
137 GL_PAINT_TRANSFORMED_OUTPUT);
138- else if (mGroups.size ())
139+ else if (!mGroups.empty ())
140 {
141 foreach (GroupSelection *group, mGroups)
142 {
143
144=== modified file 'plugins/opacify/src/opacify.cpp'
145--- plugins/opacify/src/opacify.cpp 2011-05-27 06:45:52 +0000
146+++ plugins/opacify/src/opacify.cpp 2012-07-31 13:52:21 +0000
147@@ -235,7 +235,7 @@
148 {
149 return false;
150 }
151- if (optionGetNoDelayChange () && passive.size ())
152+ if (optionGetNoDelayChange () && !passive.empty ())
153 return true;
154
155 return false;
156
157=== modified file 'plugins/ring/src/ring.cpp'
158--- plugins/ring/src/ring.cpp 2011-02-23 20:59:45 +0000
159+++ plugins/ring/src/ring.cpp 2012-07-31 13:52:21 +0000
160@@ -1138,7 +1138,7 @@
161
162 /* Terminate if the window closed was the last window in the list */
163
164- if (!mWindows.size ())
165+ if (mWindows.empty ())
166 {
167 CompOption o ("root", CompOption::TypeInt);
168 CompOption::Vector opts;
169
170=== modified file 'plugins/scale/src/scale.cpp'
171--- plugins/scale/src/scale.cpp 2012-06-22 10:10:44 +0000
172+++ plugins/scale/src/scale.cpp 2012-07-31 13:52:21 +0000
173@@ -517,7 +517,7 @@
174 case ScaleOptions::MultioutputModeOnAllOutputDevices:
175 {
176 SlotArea::vector slotAreas = getSlotAreas ();
177- if (slotAreas.size ())
178+ if (!slotAreas.empty ())
179 {
180 foreach (SlotArea &sa, slotAreas)
181 layoutSlotsForArea (sa.workArea, sa.nWindows);
182
183=== modified file 'plugins/thumbnail/src/thumbnail.cpp'
184--- plugins/thumbnail/src/thumbnail.cpp 2012-05-27 04:32:55 +0000
185+++ plugins/thumbnail/src/thumbnail.cpp 2012-07-31 13:52:21 +0000
186@@ -803,7 +803,7 @@
187 if (oldThumb.opacity > 0.0 && oldThumb.opacity < 1.0)
188 damageThumbs.push_back (&oldThumb);
189
190- if (damageThumbs.size ())
191+ if (!damageThumbs.empty ())
192 {
193 foreach (Thumbnail *t, damageThumbs)
194 damageThumbRegion (t);
195
196=== modified file 'plugins/wallpaper/src/wallpaper.cpp'
197--- plugins/wallpaper/src/wallpaper.cpp 2011-02-24 06:32:45 +0000
198+++ plugins/wallpaper/src/wallpaper.cpp 2012-07-31 13:52:21 +0000
199@@ -370,7 +370,7 @@
200 {
201 screen->handleEvent (event);
202
203- if (!screen->desktopWindowCount () && fakeDesktop == None && backgroundsPrimary.size())
204+ if (!screen->desktopWindowCount () && fakeDesktop == None && !backgroundsPrimary.empty())
205 createFakeDesktopWindow ();
206
207 if ((screen->desktopWindowCount () > 1 || backgroundsPrimary.empty())
208@@ -571,7 +571,7 @@
209 {
210 WALLPAPER_SCREEN (screen);
211
212- if ((!ws->desktop || ws->desktop == window) && ws->backgroundsPrimary.size() &&
213+ if ((!ws->desktop || ws->desktop == window) && !ws->backgroundsPrimary.empty() &&
214 window->alpha () && window->type () & CompWindowTypeDesktopMask)
215 {
216 int filterIdx;
217
218=== modified file 'src/match.cpp'
219--- src/match.cpp 2012-04-24 16:39:22 +0000
220+++ src/match.cpp 2012-07-31 13:52:21 +0000
221@@ -391,7 +391,7 @@
222 }
223 }
224
225- if (list.size ())
226+ if (!list.empty ())
227 list.front ()->flags &= ~MATCH_OP_AND_MASK;
228
229 }
230
231=== modified file 'src/screen.cpp'
232--- src/screen.cpp 2012-06-24 09:00:27 +0000
233+++ src/screen.cpp 2012-07-31 13:52:21 +0000
234@@ -2130,7 +2130,7 @@
235 CompString name;
236 CompOption::Value value;
237
238- if (screenInfo.size ())
239+ if (!screenInfo.empty ())
240 {
241 CompOption::Value::Vector l;
242 foreach (XineramaScreenInfo xi, screenInfo)

Subscribers

People subscribed via source and target branches