Merge lp:~brandontschaefer/unity/uninitialized-launcher-model into lp:unity

Proposed by Brandon Schaefer on 2012-01-24
Status: Merged
Approved by: Tim Penhey on 2012-01-26
Approved revision: 1862
Merged at revision: 1863
Proposed branch: lp:~brandontschaefer/unity/uninitialized-launcher-model
Merge into: lp:unity
Diff against target: 131 lines (+23/-29)
1 file modified
plugins/unityshell/src/LauncherModel.cpp (+23/-29)
To merge this branch: bzr merge lp:~brandontschaefer/unity/uninitialized-launcher-model
Reviewer Review Type Date Requested Status
Tim Penhey (community) 2012-01-24 Approve on 2012-01-26
Review via email: mp+89819@code.launchpad.net

Description of the Change

Just refactoring, and removing unused variable to clean up valgrind results.

Covered by existing tests.

To post a comment you must log in.
Tim Penhey (thumper) wrote :

Hmm... these are not uninitialized as they are std::list objects that have a default constructor.

1859. By Brandon Schaefer on 2012-01-24

Removed un used vars and changed for loops to use range based

1860. By Brandon Schaefer on 2012-01-24

Changed 2 more for loops to use range based instead

1861. By Brandon Schaefer on 2012-01-24

Missed removing unsued iterator

1862. By Brandon Schaefer on 2012-01-25

Changed variable name from it to icon_it because it isn't an itertor but a refrence to an icon

Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/LauncherModel.cpp'
2--- plugins/unityshell/src/LauncherModel.cpp 2012-01-10 08:12:43 +0000
3+++ plugins/unityshell/src/LauncherModel.cpp 2012-01-25 03:07:26 +0000
4@@ -66,19 +66,17 @@
5
6 _inner.clear();
7
8- iterator it, it2;
9-
10 int i = 0;
11- for (it = main_begin(); it != main_end(); it++)
12+ for (auto icon : _inner_main)
13 {
14- _inner.push_back(*it);
15- (*it)->SetSortPriority(i++);
16+ _inner.push_back(icon);
17+ icon->SetSortPriority(i++);
18 }
19
20- for (it = shelf_begin(); it != shelf_end(); it++)
21+ for (auto icon : _inner_shelf)
22 {
23- _inner.push_back(*it);
24- (*it)->SetSortPriority(i++);
25+ _inner.push_back(icon);
26+ icon->SetSortPriority(i++);
27 }
28
29 return !std::equal(begin(), end(), copy.begin());
30@@ -195,35 +193,33 @@
31 if (icon == other)
32 return;
33
34- LauncherModel::iterator it;
35-
36 int i = 0;
37 int j = 0;
38- for (it = begin(); it != end(); it++)
39+ for (auto icon_it : _inner)
40 {
41- if ((*it) == icon)
42+ if (icon_it == icon)
43 {
44 j++;
45 continue;
46 }
47
48- if ((*it) == other)
49+ if (icon_it == other)
50 {
51 icon->SetSortPriority(i);
52 if (i != j && save)
53- (*it)->SaveCenter();
54+ icon_it->SaveCenter();
55 i++;
56
57- (*it)->SetSortPriority(i);
58+ icon_it->SetSortPriority(i);
59 if (i != j && save)
60- (*it)->SaveCenter();
61+ icon_it->SaveCenter();
62 i++;
63 }
64 else
65 {
66- (*it)->SetSortPriority(i);
67+ icon_it->SetSortPriority(i);
68 if (i != j && save)
69- (*it)->SaveCenter();
70+ icon_it->SaveCenter();
71 i++;
72 }
73 j++;
74@@ -238,48 +234,46 @@
75 if (icon == other)
76 return;
77
78- LauncherModel::iterator it;
79-
80 int i = 0;
81 int j = 0;
82 bool skipped = false;
83- for (it = begin(); it != end(); it++)
84+ for (auto icon_it : _inner)
85 {
86- if ((*it) == icon)
87+ if (icon_it == icon)
88 {
89 skipped = true;
90 j++;
91 continue;
92 }
93
94- if ((*it) == other)
95+ if (icon_it == other)
96 {
97 if (!skipped)
98 {
99 icon->SetSortPriority(i);
100 if (i != j && save)
101- (*it)->SaveCenter();
102+ icon_it->SaveCenter();
103 i++;
104 }
105
106- (*it)->SetSortPriority(i);
107+ icon_it->SetSortPriority(i);
108 if (i != j && save)
109- (*it)->SaveCenter();
110+ icon_it->SaveCenter();
111 i++;
112
113 if (skipped)
114 {
115 icon->SetSortPriority(i);
116 if (i != j && save)
117- (*it)->SaveCenter();
118+ icon_it->SaveCenter();
119 i++;
120 }
121 }
122 else
123 {
124- (*it)->SetSortPriority(i);
125+ icon_it->SetSortPriority(i);
126 if (i != j && save)
127- (*it)->SaveCenter();
128+ icon_it->SaveCenter();
129 i++;
130 }
131 j++;