tools/qlist.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6const QListData::Data QListData::shared_null = { { { (-1) } }, 0, 0, 0, { 0 } }; -
7 -
8static int grow(int size) -
9{ -
10 -
11 volatile int x = qAllocMore(size * sizeof(void *), QListData::DataHeaderSize) / sizeof(void *); -
12 return x;
executed: return x;
Execution Count:1053559
1053559
13} -
14QListData::Data *QListData::detach_grow(int *idx, int num) -
15{ -
16 Data *x = d; -
17 int l = x->end - x->begin; -
18 int nl = l + num; -
19 int alloc = grow(nl); -
20 Data* t = static_cast<Data *>(::malloc(DataHeaderSize + alloc * sizeof(void *))); -
21 do { if (!(t)) qBadAlloc(); } while (0);
never executed: qBadAlloc();
executed: }
Execution Count:817133
partially evaluated: !(t)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:817134
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:817126
0-817134
22 -
23 t->ref.initializeOwned(); -
24 t->alloc = alloc; -
25 -
26 -
27 -
28 -
29 -
30 -
31 int bg; -
32 if (*idx < 0) {
partially evaluated: *idx < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:817126
0-817126
33 *idx = 0; -
34 bg = (alloc - nl) >> 1; -
35 } else if (*idx > l) {
never executed: }
evaluated: *idx > l
TRUEFALSE
yes
Evaluation Count:761434
yes
Evaluation Count:55696
0-761434
36 *idx = l; -
37 bg = 0; -
38 } else if (*idx < (l >> 1)) {
executed: }
Execution Count:761433
evaluated: *idx < (l >> 1)
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:55590
106-761433
39 bg = (alloc - nl) >> 1; -
40 } else {
executed: }
Execution Count:106
106
41 bg = 0; -
42 }
executed: }
Execution Count:55590
55590
43 t->begin = bg; -
44 t->end = bg + nl; -
45 d = t; -
46 -
47 return x;
executed: return x;
Execution Count:817126
817126
48} -
49QListData::Data *QListData::detach(int alloc) -
50{ -
51 Data *x = d; -
52 Data* t = static_cast<Data *>(::malloc(DataHeaderSize + alloc * sizeof(void *))); -
53 do { if (!(t)) qBadAlloc(); } while (0);
partially evaluated: !(t)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:83251
never executed: qBadAlloc();
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:83251
executed: }
Execution Count:83251
0-83251
54 -
55 t->ref.initializeOwned(); -
56 t->alloc = alloc; -
57 if (!alloc) {
evaluated: !alloc
TRUEFALSE
yes
Evaluation Count:17658
yes
Evaluation Count:65593
17658-65593
58 t->begin = 0; -
59 t->end = 0; -
60 } else {
executed: }
Execution Count:17658
17658
61 t->begin = x->begin; -
62 t->end = x->end; -
63 }
executed: }
Execution Count:65593
65593
64 d = t; -
65 -
66 return x;
executed: return x;
Execution Count:83251
83251
67} -
68 -
69void QListData::realloc(int alloc) -
70{ -
71 qt_noop(); -
72 Data *x = static_cast<Data *>(::realloc(d, DataHeaderSize + alloc * sizeof(void *))); -
73 do { if (!(x)) qBadAlloc(); } while (0);
never executed: qBadAlloc();
executed: }
Execution Count:236434
partially evaluated: !(x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:236434
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:236434
0-236434
74 -
75 d = x; -
76 d->alloc = alloc; -
77 if (!alloc)
partially evaluated: !alloc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:236434
0-236434
78 d->begin = d->end = 0;
never executed: d->begin = d->end = 0;
0
79}
executed: }
Execution Count:236434
236434
80 -
81void QListData::dispose(Data *d) -
82{ -
83 qt_noop(); -
84 free(d); -
85}
executed: }
Execution Count:901061
901061
86 -
87 -
88void **QListData::append(int n) -
89{ -
90 qt_noop(); -
91 int e = d->end; -
92 if (e + n > d->alloc) {
evaluated: e + n > d->alloc
TRUEFALSE
yes
Evaluation Count:282396
yes
Evaluation Count:6671648
282396-6671648
93 int b = d->begin; -
94 if (b - n >= 2 * d->alloc / 3) {
evaluated: b - n >= 2 * d->alloc / 3
TRUEFALSE
yes
Evaluation Count:70983
yes
Evaluation Count:211413
70983-211413
95 -
96 e -= b; -
97 ::memcpy(d->array, d->array + b, e * sizeof(void *)); -
98 d->begin = 0; -
99 } else {
executed: }
Execution Count:70982
70982
100 realloc(grow(d->alloc + n)); -
101 }
executed: }
Execution Count:211414
211414
102 } -
103 d->end = e + n; -
104 return d->array + e;
executed: return d->array + e;
Execution Count:6954023
6954023
105} -
106 -
107 -
108void **QListData::append() -
109{ -
110 return append(1);
executed: return append(1);
Execution Count:6950936
6950936
111} -
112 -
113 -
114void **QListData::append(const QListData& l) -
115{ -
116 return append(l.d->end - l.d->begin);
executed: return append(l.d->end - l.d->begin);
Execution Count:1772
1772
117} -
118 -
119void **QListData::prepend() -
120{ -
121 qt_noop(); -
122 if (d->begin == 0) {
evaluated: d->begin == 0
TRUEFALSE
yes
Evaluation Count:25372
yes
Evaluation Count:4248307
25372-4248307
123 if (d->end >= d->alloc / 3)
evaluated: d->end >= d->alloc / 3
TRUEFALSE
yes
Evaluation Count:24906
yes
Evaluation Count:466
466-24906
124 realloc(grow(d->alloc + 1));
executed: realloc(grow(d->alloc + 1));
Execution Count:24906
24906
125 -
126 if (d->end < d->alloc / 3)
evaluated: d->end < d->alloc / 3
TRUEFALSE
yes
Evaluation Count:18529
yes
Evaluation Count:6843
6843-18529
127 d->begin = d->alloc - 2 * d->end;
executed: d->begin = d->alloc - 2 * d->end;
Execution Count:18529
18529
128 else -
129 d->begin = d->alloc - d->end;
executed: d->begin = d->alloc - d->end;
Execution Count:6843
6843
130 -
131 ::memmove(d->array + d->begin, d->array, d->end * sizeof(void *)); -
132 d->end += d->begin; -
133 }
executed: }
Execution Count:25372
25372
134 return d->array + --d->begin;
executed: return d->array + --d->begin;
Execution Count:4273679
4273679
135} -
136 -
137void **QListData::insert(int i) -
138{ -
139 qt_noop(); -
140 if (i <= 0)
evaluated: i <= 0
TRUEFALSE
yes
Evaluation Count:4223476
yes
Evaluation Count:1894015
1894015-4223476
141 return prepend();
executed: return prepend();
Execution Count:4223476
4223476
142 int size = d->end - d->begin; -
143 if (i >= size)
evaluated: i >= size
TRUEFALSE
yes
Evaluation Count:1844889
yes
Evaluation Count:49126
49126-1844889
144 return append();
executed: return append();
Execution Count:1844889
1844889
145 -
146 bool leftward = false; -
147 -
148 if (d->begin == 0) {
evaluated: d->begin == 0
TRUEFALSE
yes
Evaluation Count:3199
yes
Evaluation Count:45927
3199-45927
149 if (d->end == d->alloc) {
evaluated: d->end == d->alloc
TRUEFALSE
yes
Evaluation Count:114
yes
Evaluation Count:3085
114-3085
150 -
151 realloc(grow(d->alloc + 1)); -
152 } else {
executed: }
Execution Count:114
114
153 -
154 }
executed: }
Execution Count:3085
3085
155 } else { -
156 if (d->end == d->alloc) {
evaluated: d->end == d->alloc
TRUEFALSE
yes
Evaluation Count:17815
yes
Evaluation Count:28112
17815-28112
157 -
158 leftward = true; -
159 } else {
executed: }
Execution Count:17815
17815
160 -
161 leftward = (i < size - i); -
162 }
executed: }
Execution Count:28112
28112
163 } -
164 -
165 if (leftward) {
evaluated: leftward
TRUEFALSE
yes
Evaluation Count:19452
yes
Evaluation Count:29674
19452-29674
166 --d->begin; -
167 ::memmove(d->array + d->begin, d->array + d->begin + 1, i * sizeof(void *)); -
168 } else {
executed: }
Execution Count:19452
19452
169 ::memmove(d->array + d->begin + i + 1, d->array + d->begin + i, -
170 (size - i) * sizeof(void *)); -
171 ++d->end; -
172 }
executed: }
Execution Count:29674
29674
173 return d->array + d->begin + i;
executed: return d->array + d->begin + i;
Execution Count:49126
49126
174} -
175 -
176void QListData::remove(int i) -
177{ -
178 qt_noop(); -
179 i += d->begin; -
180 if (i - d->begin < d->end - i) {
evaluated: i - d->begin < d->end - i
TRUEFALSE
yes
Evaluation Count:6749003
yes
Evaluation Count:670433
670433-6749003
181 if (int offset = i - d->begin)
evaluated: int offset = i - d->begin
TRUEFALSE
yes
Evaluation Count:27254
yes
Evaluation Count:6721749
27254-6721749
182 ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *));
executed: ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *));
Execution Count:27254
27254
183 d->begin++; -
184 } else {
executed: }
Execution Count:6749002
6749002
185 if (int offset = d->end - i - 1)
evaluated: int offset = d->end - i - 1
TRUEFALSE
yes
Evaluation Count:516649
yes
Evaluation Count:153784
153784-516649
186 ::memmove(d->array + i, d->array + i + 1, offset * sizeof(void *));
executed: ::memmove(d->array + i, d->array + i + 1, offset * sizeof(void *));
Execution Count:516649
516649
187 d->end--; -
188 }
executed: }
Execution Count:670433
670433
189} -
190 -
191void QListData::remove(int i, int n) -
192{ -
193 qt_noop(); -
194 i += d->begin; -
195 int middle = i + n/2; -
196 if (middle - d->begin < d->end - middle) {
evaluated: middle - d->begin < d->end - middle
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:109333
43-109333
197 ::memmove(d->array + d->begin + n, d->array + d->begin, -
198 (i - d->begin) * sizeof(void*)); -
199 d->begin += n; -
200 } else {
executed: }
Execution Count:43
43
201 ::memmove(d->array + i, d->array + i + n, -
202 (d->end - i - n) * sizeof(void*)); -
203 d->end -= n; -
204 }
executed: }
Execution Count:109332
109332
205} -
206 -
207void QListData::move(int from, int to) -
208{ -
209 qt_noop(); -
210 if (from == to)
evaluated: from == to
TRUEFALSE
yes
Evaluation Count:4329
yes
Evaluation Count:5950
4329-5950
211 return;
executed: return;
Execution Count:4329
4329
212 -
213 from += d->begin; -
214 to += d->begin; -
215 void *t = d->array[from]; -
216 -
217 if (from < to) {
evaluated: from < to
TRUEFALSE
yes
Evaluation Count:4584
yes
Evaluation Count:1366
1366-4584
218 if (d->end == d->alloc || 3 * (to - from) < 2 * (d->end - d->begin)) {
evaluated: d->end == d->alloc
TRUEFALSE
yes
Evaluation Count:1133
yes
Evaluation Count:3451
evaluated: 3 * (to - from) < 2 * (d->end - d->begin)
TRUEFALSE
yes
Evaluation Count:2640
yes
Evaluation Count:811
811-3451
219 ::memmove(d->array + from, d->array + from + 1, (to - from) * sizeof(void *)); -
220 } else {
executed: }
Execution Count:3773
3773
221 -
222 if (int offset = from - d->begin)
evaluated: int offset = from - d->begin
TRUEFALSE
yes
Evaluation Count:474
yes
Evaluation Count:337
337-474
223 ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *));
executed: ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *));
Execution Count:474
474
224 if (int offset = d->end - (to + 1))
partially evaluated: int offset = d->end - (to + 1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:811
0-811
225 ::memmove(d->array + to + 2, d->array + to + 1, offset * sizeof(void *));
never executed: ::memmove(d->array + to + 2, d->array + to + 1, offset * sizeof(void *));
0
226 ++d->begin; -
227 ++d->end; -
228 ++to; -
229 }
executed: }
Execution Count:811
811
230 } else { -
231 if (d->begin == 0 || 3 * (from - to) < 2 * (d->end - d->begin)) {
evaluated: d->begin == 0
TRUEFALSE
yes
Evaluation Count:899
yes
Evaluation Count:467
evaluated: 3 * (from - to) < 2 * (d->end - d->begin)
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:432
35-899
232 ::memmove(d->array + to + 1, d->array + to, (from - to) * sizeof(void *)); -
233 } else {
executed: }
Execution Count:934
934
234 -
235 if (int offset = to - d->begin)
partially evaluated: int offset = to - d->begin
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:432
0-432
236 ::memmove(d->array + d->begin - 1, d->array + d->begin, offset * sizeof(void *));
never executed: ::memmove(d->array + d->begin - 1, d->array + d->begin, offset * sizeof(void *));
0
237 if (int offset = d->end - (from + 1))
evaluated: int offset = d->end - (from + 1)
TRUEFALSE
yes
Evaluation Count:388
yes
Evaluation Count:44
44-388
238 ::memmove(d->array + from, d->array + from + 1, offset * sizeof(void *));
executed: ::memmove(d->array + from, d->array + from + 1, offset * sizeof(void *));
Execution Count:388
388
239 --d->begin; -
240 --d->end; -
241 --to; -
242 }
executed: }
Execution Count:432
432
243 } -
244 d->array[to] = t; -
245}
executed: }
Execution Count:5950
5950
246 -
247void **QListData::erase(void **xi) -
248{ -
249 qt_noop(); -
250 int i = xi - (d->array + d->begin); -
251 remove(i); -
252 return d->array + d->begin + i;
executed: return d->array + d->begin + i;
Execution Count:7164638
7164638
253} -
254 -
255 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial