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:943799
943799
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:718974
partially evaluated: !(t)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:718972
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:718968
0-718974
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:718968
0-718968
33 *idx = 0; -
34 bg = (alloc - nl) >> 1; -
35 } else if (*idx > l) {
never executed: }
evaluated: *idx > l
TRUEFALSE
yes
Evaluation Count:675954
yes
Evaluation Count:43015
0-675954
36 *idx = l; -
37 bg = 0; -
38 } else if (*idx < (l >> 1)) {
executed: }
Execution Count:675953
evaluated: *idx < (l >> 1)
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:42909
106-675953
39 bg = (alloc - nl) >> 1; -
40 } else {
executed: }
Execution Count:106
106
41 bg = 0; -
42 }
executed: }
Execution Count:42909
42909
43 t->begin = bg; -
44 t->end = bg + nl; -
45 d = t; -
46 -
47 return x;
executed: return x;
Execution Count:718969
718969
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:70658
never executed: qBadAlloc();
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70658
executed: }
Execution Count:70658
0-70658
54 -
55 t->ref.initializeOwned(); -
56 t->alloc = alloc; -
57 if (!alloc) {
evaluated: !alloc
TRUEFALSE
yes
Evaluation Count:15164
yes
Evaluation Count:55494
15164-55494
58 t->begin = 0; -
59 t->end = 0; -
60 } else {
executed: }
Execution Count:15164
15164
61 t->begin = x->begin; -
62 t->end = x->end; -
63 }
executed: }
Execution Count:55494
55494
64 d = t; -
65 -
66 return x;
executed: return x;
Execution Count:70658
70658
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:224838
partially evaluated: !(x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:224837
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:224835
0-224838
74 -
75 d = x; -
76 d->alloc = alloc; -
77 if (!alloc)
partially evaluated: !alloc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:224836
0-224836
78 d->begin = d->end = 0;
never executed: d->begin = d->end = 0;
0
79}
executed: }
Execution Count:224836
224836
80 -
81void QListData::dispose(Data *d) -
82{ -
83 qt_noop(); -
84 free(d); -
85}
executed: }
Execution Count:789603
789603
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:293668
yes
Evaluation Count:6264694
293668-6264694
93 int b = d->begin; -
94 if (b - n >= 2 * d->alloc / 3) {
evaluated: b - n >= 2 * d->alloc / 3
TRUEFALSE
yes
Evaluation Count:90117
yes
Evaluation Count:203551
90117-203551
95 -
96 e -= b; -
97 ::memcpy(d->array, d->array + b, e * sizeof(void *)); -
98 d->begin = 0; -
99 } else {
executed: }
Execution Count:90117
90117
100 realloc(grow(d->alloc + n)); -
101 }
executed: }
Execution Count:203552
203552
102 } -
103 d->end = e + n; -
104 return d->array + e;
executed: return d->array + e;
Execution Count:6558057
6558057
105} -
106 -
107 -
108void **QListData::append() -
109{ -
110 return append(1);
executed: return append(1);
Execution Count:6556691
6556691
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:1555
1555
117} -
118 -
119void **QListData::prepend() -
120{ -
121 qt_noop(); -
122 if (d->begin == 0) {
evaluated: d->begin == 0
TRUEFALSE
yes
Evaluation Count:21508
yes
Evaluation Count:4240065
21508-4240065
123 if (d->end >= d->alloc / 3)
evaluated: d->end >= d->alloc / 3
TRUEFALSE
yes
Evaluation Count:21176
yes
Evaluation Count:332
332-21176
124 realloc(grow(d->alloc + 1));
executed: realloc(grow(d->alloc + 1));
Execution Count:21176
21176
125 -
126 if (d->end < d->alloc / 3)
evaluated: d->end < d->alloc / 3
TRUEFALSE
yes
Evaluation Count:15698
yes
Evaluation Count:5810
5810-15698
127 d->begin = d->alloc - 2 * d->end;
executed: d->begin = d->alloc - 2 * d->end;
Execution Count:15698
15698
128 else -
129 d->begin = d->alloc - d->end;
executed: d->begin = d->alloc - d->end;
Execution Count:5810
5810
130 -
131 ::memmove(d->array + d->begin, d->array, d->end * sizeof(void *)); -
132 d->end += d->begin; -
133 }
executed: }
Execution Count:21508
21508
134 return d->array + --d->begin;
executed: return d->array + --d->begin;
Execution Count:4261573
4261573
135} -
136 -
137void **QListData::insert(int i) -
138{ -
139 qt_noop(); -
140 if (i <= 0)
evaluated: i <= 0
TRUEFALSE
yes
Evaluation Count:4222026
yes
Evaluation Count:1924829
1924829-4222026
141 return prepend();
executed: return prepend();
Execution Count:4222026
4222026
142 int size = d->end - d->begin; -
143 if (i >= size)
evaluated: i >= size
TRUEFALSE
yes
Evaluation Count:1878392
yes
Evaluation Count:46437
46437-1878392
144 return append();
executed: return append();
Execution Count:1878392
1878392
145 -
146 bool leftward = false; -
147 -
148 if (d->begin == 0) {
evaluated: d->begin == 0
TRUEFALSE
yes
Evaluation Count:3050
yes
Evaluation Count:43387
3050-43387
149 if (d->end == d->alloc) {
evaluated: d->end == d->alloc
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:2941
109-2941
150 -
151 realloc(grow(d->alloc + 1)); -
152 } else {
executed: }
Execution Count:109
109
153 -
154 }
executed: }
Execution Count:2941
2941
155 } else { -
156 if (d->end == d->alloc) {
evaluated: d->end == d->alloc
TRUEFALSE
yes
Evaluation Count:16264
yes
Evaluation Count:27123
16264-27123
157 -
158 leftward = true; -
159 } else {
executed: }
Execution Count:16264
16264
160 -
161 leftward = (i < size - i); -
162 }
executed: }
Execution Count:27123
27123
163 } -
164 -
165 if (leftward) {
evaluated: leftward
TRUEFALSE
yes
Evaluation Count:17809
yes
Evaluation Count:28628
17809-28628
166 --d->begin; -
167 ::memmove(d->array + d->begin, d->array + d->begin + 1, i * sizeof(void *)); -
168 } else {
executed: }
Execution Count:17809
17809
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:28628
28628
173 return d->array + d->begin + i;
executed: return d->array + d->begin + i;
Execution Count:46437
46437
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:6768738
yes
Evaluation Count:663824
663824-6768738
181 if (int offset = i - d->begin)
evaluated: int offset = i - d->begin
TRUEFALSE
yes
Evaluation Count:25623
yes
Evaluation Count:6743115
25623-6743115
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:25623
25623
183 d->begin++; -
184 } else {
executed: }
Execution Count:6768737
6768737
185 if (int offset = d->end - i - 1)
evaluated: int offset = d->end - i - 1
TRUEFALSE
yes
Evaluation Count:517490
yes
Evaluation Count:146334
146334-517490
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:517490
517490
187 d->end--; -
188 }
executed: }
Execution Count:663824
663824
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:29
yes
Evaluation Count:106657
29-106657
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:29
29
201 ::memmove(d->array + i, d->array + i + n, -
202 (d->end - i - n) * sizeof(void*)); -
203 d->end -= n; -
204 }
executed: }
Execution Count:106658
106658
205} -
206 -
207void QListData::move(int from, int to) -
208{ -
209 qt_noop(); -
210 if (from == to)
evaluated: from == to
TRUEFALSE
yes
Evaluation Count:489
yes
Evaluation Count:3225
489-3225
211 return;
executed: return;
Execution Count:489
489
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:2358
yes
Evaluation Count:867
867-2358
218 if (d->end == d->alloc || 3 * (to - from) < 2 * (d->end - d->begin)) {
evaluated: d->end == d->alloc
TRUEFALSE
yes
Evaluation Count:457
yes
Evaluation Count:1901
evaluated: 3 * (to - from) < 2 * (d->end - d->begin)
TRUEFALSE
yes
Evaluation Count:1479
yes
Evaluation Count:422
422-1901
219 ::memmove(d->array + from, d->array + from + 1, (to - from) * sizeof(void *)); -
220 } else {
executed: }
Execution Count:1936
1936
221 -
222 if (int offset = from - d->begin)
evaluated: int offset = from - d->begin
TRUEFALSE
yes
Evaluation Count:367
yes
Evaluation Count:55
55-367
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:367
367
224 if (int offset = d->end - (to + 1))
partially evaluated: int offset = d->end - (to + 1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:422
0-422
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:422
422
230 } else { -
231 if (d->begin == 0 || 3 * (from - to) < 2 * (d->end - d->begin)) {
evaluated: d->begin == 0
TRUEFALSE
yes
Evaluation Count:460
yes
Evaluation Count:407
evaluated: 3 * (from - to) < 2 * (d->end - d->begin)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:393
14-460
232 ::memmove(d->array + to + 1, d->array + to, (from - to) * sizeof(void *)); -
233 } else {
executed: }
Execution Count:474
474
234 -
235 if (int offset = to - d->begin)
partially evaluated: int offset = to - d->begin
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:393
0-393
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:381
yes
Evaluation Count:12
12-381
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:381
381
239 --d->begin; -
240 --d->end; -
241 --to; -
242 }
executed: }
Execution Count:393
393
243 } -
244 d->array[to] = t; -
245}
executed: }
Execution Count:3225
3225
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:7192612
7192612
253} -
254 -
255 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial