Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4sparsearray.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | using namespace QV4; | - | ||||||||||||||||||
9 | - | |||||||||||||||||||
10 | const SparseArrayNode *SparseArrayNode::nextNode() const | - | ||||||||||||||||||
11 | { | - | ||||||||||||||||||
12 | const SparseArrayNode *n = this; | - | ||||||||||||||||||
13 | if (n->right
| 293-1253 | ||||||||||||||||||
14 | n = n->right; | - | ||||||||||||||||||
15 | while (n->left
| 4-294 | ||||||||||||||||||
16 | n = n->left; executed 4 times by 1 test: n = n->left; Executed by:
| 4 | ||||||||||||||||||
17 | } executed 293 times by 2 tests: else {end of block Executed by:
| 293 | ||||||||||||||||||
18 | const SparseArrayNode *y = n->parent(); | - | ||||||||||||||||||
19 | while (y
| 0-1747 | ||||||||||||||||||
20 | n = y; | - | ||||||||||||||||||
21 | y = n->parent(); | - | ||||||||||||||||||
22 | } executed 494 times by 2 tests: end of block Executed by:
| 494 | ||||||||||||||||||
23 | n = y; | - | ||||||||||||||||||
24 | } executed 1254 times by 2 tests: end of block Executed by:
| 1254 | ||||||||||||||||||
25 | return executed 1548 times by 2 tests: n;return n; Executed by:
executed 1548 times by 2 tests: return n; Executed by:
| 1548 | ||||||||||||||||||
26 | } | - | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | const SparseArrayNode *SparseArrayNode::previousNode() const | - | ||||||||||||||||||
29 | { | - | ||||||||||||||||||
30 | const SparseArrayNode *n = this; | - | ||||||||||||||||||
31 | if (n->left
| 180-182 | ||||||||||||||||||
32 | n = n->left; | - | ||||||||||||||||||
33 | while (n->right
| 182-256 | ||||||||||||||||||
34 | n = n->right; executed 256 times by 1 test: n = n->right; Executed by:
| 256 | ||||||||||||||||||
35 | } executed 182 times by 1 test: else {end of block Executed by:
| 182 | ||||||||||||||||||
36 | const SparseArrayNode *y = n->parent(); | - | ||||||||||||||||||
37 | while (y
| 4-178 | ||||||||||||||||||
38 | n = y; | - | ||||||||||||||||||
39 | y = n->parent(); | - | ||||||||||||||||||
40 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
41 | n = y; | - | ||||||||||||||||||
42 | } executed 180 times by 1 test: end of block Executed by:
| 180 | ||||||||||||||||||
43 | return executed 362 times by 1 test: n;return n; Executed by:
executed 362 times by 1 test: return n; Executed by:
| 362 | ||||||||||||||||||
44 | } | - | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | SparseArrayNode *SparseArrayNode::copy(SparseArray *d) const | - | ||||||||||||||||||
47 | { | - | ||||||||||||||||||
48 | SparseArrayNode *n = d->createNode(size_left, nullptr, false); | - | ||||||||||||||||||
49 | n->value = value; | - | ||||||||||||||||||
50 | n->setColor(color()); | - | ||||||||||||||||||
51 | if (left
| 0 | ||||||||||||||||||
52 | n->left = left->copy(d); | - | ||||||||||||||||||
53 | n->left->setParent(n); | - | ||||||||||||||||||
54 | } never executed: else {end of block | 0 | ||||||||||||||||||
55 | n->left = nullptr; | - | ||||||||||||||||||
56 | } never executed: end of block | 0 | ||||||||||||||||||
57 | if (right
| 0 | ||||||||||||||||||
58 | n->right = right->copy(d); | - | ||||||||||||||||||
59 | n->right->setParent(n); | - | ||||||||||||||||||
60 | } never executed: else {end of block | 0 | ||||||||||||||||||
61 | n->right = nullptr; | - | ||||||||||||||||||
62 | } never executed: end of block | 0 | ||||||||||||||||||
63 | return never executed: n;return n; never executed: return n; | 0 | ||||||||||||||||||
64 | } | - | ||||||||||||||||||
65 | void SparseArray::rotateLeft(SparseArrayNode *x) | - | ||||||||||||||||||
66 | { | - | ||||||||||||||||||
67 | SparseArrayNode *&root = header.left; | - | ||||||||||||||||||
68 | SparseArrayNode *y = x->right; | - | ||||||||||||||||||
69 | x->right = y->left; | - | ||||||||||||||||||
70 | if (y->left != nullptr
| 36-1081 | ||||||||||||||||||
71 | y->left->setParent(x); executed 36 times by 1 test: y->left->setParent(x); Executed by:
| 36 | ||||||||||||||||||
72 | y->setParent(x->parent()); | - | ||||||||||||||||||
73 | if (x == root
| 177-942 | ||||||||||||||||||
74 | root = y; executed 939 times by 1 test: root = y; Executed by:
| 939 | ||||||||||||||||||
75 | else if (x == x->parent()->left
| 23-154 | ||||||||||||||||||
76 | x->parent()->left = y; executed 23 times by 1 test: x->parent()->left = y; Executed by:
| 23 | ||||||||||||||||||
77 | else | - | ||||||||||||||||||
78 | x->parent()->right = y; executed 154 times by 1 test: x->parent()->right = y; Executed by:
| 154 | ||||||||||||||||||
79 | y->left = x; | - | ||||||||||||||||||
80 | x->setParent(y); | - | ||||||||||||||||||
81 | y->size_left += x->size_left; | - | ||||||||||||||||||
82 | } executed 1119 times by 1 test: end of block Executed by:
| 1119 | ||||||||||||||||||
83 | void SparseArray::rotateRight(SparseArrayNode *x) | - | ||||||||||||||||||
84 | { | - | ||||||||||||||||||
85 | SparseArrayNode *&root = header.left; | - | ||||||||||||||||||
86 | SparseArrayNode *y = x->left; | - | ||||||||||||||||||
87 | x->left = y->right; | - | ||||||||||||||||||
88 | if (y->right != nullptr
| 0-179 | ||||||||||||||||||
89 | y->right->setParent(x); never executed: y->right->setParent(x); | 0 | ||||||||||||||||||
90 | y->setParent(x->parent()); | - | ||||||||||||||||||
91 | if (x == root
| 20-160 | ||||||||||||||||||
92 | root = y; executed 20 times by 1 test: root = y; Executed by:
| 20 | ||||||||||||||||||
93 | else if (x == x->parent()->right
| 0-160 | ||||||||||||||||||
94 | x->parent()->right = y; executed 160 times by 1 test: x->parent()->right = y; Executed by:
| 160 | ||||||||||||||||||
95 | else | - | ||||||||||||||||||
96 | x->parent()->left = y; never executed: x->parent()->left = y; | 0 | ||||||||||||||||||
97 | y->right = x; | - | ||||||||||||||||||
98 | x->setParent(y); | - | ||||||||||||||||||
99 | x->size_left -= y->size_left; | - | ||||||||||||||||||
100 | } executed 180 times by 1 test: end of block Executed by:
| 180 | ||||||||||||||||||
101 | - | |||||||||||||||||||
102 | - | |||||||||||||||||||
103 | void SparseArray::rebalance(SparseArrayNode *x) | - | ||||||||||||||||||
104 | { | - | ||||||||||||||||||
105 | SparseArrayNode *&root = header.left; | - | ||||||||||||||||||
106 | x->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
107 | while (x != root
| 1518-4389 | ||||||||||||||||||
108 | if (x->parent() == x->parent()->parent()->left
| 50-1468 | ||||||||||||||||||
109 | SparseArrayNode *y = x->parent()->parent()->right; | - | ||||||||||||||||||
110 | if (y
| 0-26 | ||||||||||||||||||
111 | x->parent()->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
112 | y->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
113 | x->parent()->parent()->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
114 | x = x->parent()->parent(); | - | ||||||||||||||||||
115 | } executed 26 times by 2 tests: else {end of block Executed by:
| 26 | ||||||||||||||||||
116 | if (x == x->parent()->right
| 8-15 | ||||||||||||||||||
117 | x = x->parent(); | - | ||||||||||||||||||
118 | rotateLeft(x); | - | ||||||||||||||||||
119 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
120 | x->parent()->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
121 | x->parent()->parent()->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
122 | rotateRight (x->parent()->parent()); | - | ||||||||||||||||||
123 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||
124 | } else { | - | ||||||||||||||||||
125 | SparseArrayNode *y = x->parent()->parent()->left; | - | ||||||||||||||||||
126 | if (y
| 36-1059 | ||||||||||||||||||
127 | x->parent()->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
128 | y->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
129 | x->parent()->parent()->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
130 | x = x->parent()->parent(); | - | ||||||||||||||||||
131 | } executed 370 times by 1 test: else {end of block Executed by:
| 370 | ||||||||||||||||||
132 | if (x == x->parent()->left
| 156-939 | ||||||||||||||||||
133 | x = x->parent(); | - | ||||||||||||||||||
134 | rotateRight(x); | - | ||||||||||||||||||
135 | } executed 156 times by 1 test: end of block Executed by:
| 156 | ||||||||||||||||||
136 | x->parent()->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
137 | x->parent()->parent()->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
138 | rotateLeft(x->parent()->parent()); | - | ||||||||||||||||||
139 | } executed 1096 times by 1 test: end of block Executed by:
| 1096 | ||||||||||||||||||
140 | } | - | ||||||||||||||||||
141 | } | - | ||||||||||||||||||
142 | root->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
143 | } executed 6260 times by 2 tests: end of block Executed by:
| 6260 | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | void SparseArray::deleteNode(SparseArrayNode *z) | - | ||||||||||||||||||
146 | { | - | ||||||||||||||||||
147 | SparseArrayNode *&root = header.left; | - | ||||||||||||||||||
148 | SparseArrayNode *y = z; | - | ||||||||||||||||||
149 | SparseArrayNode *x; | - | ||||||||||||||||||
150 | SparseArrayNode *x_parent; | - | ||||||||||||||||||
151 | if (y->left == nullptr
| 152-447 | ||||||||||||||||||
152 | x = y->right; | - | ||||||||||||||||||
153 | if (y == mostLeftNode
| 216-231 | ||||||||||||||||||
154 | if (x
| 10-221 | ||||||||||||||||||
155 | mostLeftNode = x; executed 10 times by 2 tests: mostLeftNode = x; Executed by:
| 10 | ||||||||||||||||||
156 | else | - | ||||||||||||||||||
157 | mostLeftNode = y->parent(); executed 221 times by 1 test: mostLeftNode = y->parent(); Executed by:
| 221 | ||||||||||||||||||
158 | } | - | ||||||||||||||||||
159 | } executed 448 times by 2 tests: else if (y->right == nullptrend of block Executed by:
| 42-448 | ||||||||||||||||||
160 | x = y->left; | - | ||||||||||||||||||
161 | } executed 42 times by 2 tests: else {end of block Executed by:
| 42 | ||||||||||||||||||
162 | y = y->right; | - | ||||||||||||||||||
163 | while (y->left != nullptr
| 0-112 | ||||||||||||||||||
164 | y = y->left; never executed: y = y->left; | 0 | ||||||||||||||||||
165 | x = y->right; | - | ||||||||||||||||||
166 | } executed 112 times by 1 test: end of block Executed by:
| 112 | ||||||||||||||||||
167 | if (y != z
| 112-489 | ||||||||||||||||||
168 | - | |||||||||||||||||||
169 | - | |||||||||||||||||||
170 | z->size_left += y->size_left; | - | ||||||||||||||||||
171 | SparseArrayNode *n = y->parent(); | - | ||||||||||||||||||
172 | while (n != z
| 0-110 | ||||||||||||||||||
173 | n->size_left -= y->size_left; | - | ||||||||||||||||||
174 | n = n->parent(); | - | ||||||||||||||||||
175 | } never executed: end of block | 0 | ||||||||||||||||||
176 | y->size_left = 0; | - | ||||||||||||||||||
177 | z->value = y->value; | - | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | if (y != z->right
| 0-112 | ||||||||||||||||||
180 | x_parent = y->parent(); | - | ||||||||||||||||||
181 | y->parent()->left = x; | - | ||||||||||||||||||
182 | } never executed: else {end of block | 0 | ||||||||||||||||||
183 | x_parent = z; | - | ||||||||||||||||||
184 | z->right = x; | - | ||||||||||||||||||
185 | } executed 112 times by 1 test: end of block Executed by:
| 112 | ||||||||||||||||||
186 | if (x
| 8-102 | ||||||||||||||||||
187 | x->setParent(x_parent); executed 8 times by 1 test: x->setParent(x_parent); Executed by:
| 8 | ||||||||||||||||||
188 | } executed 110 times by 1 test: else {end of block Executed by:
| 110 | ||||||||||||||||||
189 | x_parent = y->parent(); | - | ||||||||||||||||||
190 | if (x
| 52-437 | ||||||||||||||||||
191 | x->setParent(y->parent()); executed 52 times by 2 tests: x->setParent(y->parent()); Executed by:
| 52 | ||||||||||||||||||
192 | if (root == y
| 197-292 | ||||||||||||||||||
193 | root = x; executed 197 times by 2 tests: root = x; Executed by:
| 197 | ||||||||||||||||||
194 | else if (y->parent()->left == y
| 60-232 | ||||||||||||||||||
195 | y->parent()->left = x; executed 60 times by 2 tests: y->parent()->left = x; Executed by:
| 60 | ||||||||||||||||||
196 | else | - | ||||||||||||||||||
197 | y->parent()->right = x; executed 232 times by 1 test: y->parent()->right = x; Executed by:
| 232 | ||||||||||||||||||
198 | if (x
| 10-437 | ||||||||||||||||||
199 | x->size_left += y->size_left; executed 10 times by 2 tests: x->size_left += y->size_left; Executed by:
| 10 | ||||||||||||||||||
200 | y->size_left = 0; | - | ||||||||||||||||||
201 | } executed 490 times by 2 tests: end of block Executed by:
| 490 | ||||||||||||||||||
202 | if (y->color() != SparseArrayNode::Red
| 286-314 | ||||||||||||||||||
203 | while (x != root
| 0-251 | ||||||||||||||||||
204 | if (x == x_parent->left
| 10-52 | ||||||||||||||||||
205 | SparseArrayNode *w = x_parent->right; | - | ||||||||||||||||||
206 | if (w->color() == SparseArrayNode::Red
| 0-10 | ||||||||||||||||||
207 | w->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
208 | x_parent->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
209 | rotateLeft(x_parent); | - | ||||||||||||||||||
210 | w = x_parent->right; | - | ||||||||||||||||||
211 | } never executed: end of block | 0 | ||||||||||||||||||
212 | if ((w->left == nullptr
| 0-10 | ||||||||||||||||||
213 | (w->right == nullptr
| 0-6 | ||||||||||||||||||
214 | w->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
215 | x = x_parent; | - | ||||||||||||||||||
216 | x_parent = x_parent->parent(); | - | ||||||||||||||||||
217 | } executed 4 times by 1 test: else {end of block Executed by:
| 4 | ||||||||||||||||||
218 | if (w->right == nullptr
| 0-6 | ||||||||||||||||||
219 | if (w->left
| 0 | ||||||||||||||||||
220 | w->left->setColor(SparseArrayNode::Black); never executed: w->left->setColor(SparseArrayNode::Black); | 0 | ||||||||||||||||||
221 | w->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
222 | rotateRight(w); | - | ||||||||||||||||||
223 | w = x_parent->right; | - | ||||||||||||||||||
224 | } never executed: end of block | 0 | ||||||||||||||||||
225 | w->setColor(x_parent->color()); | - | ||||||||||||||||||
226 | x_parent->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
227 | if (w->right
| 0-6 | ||||||||||||||||||
228 | w->right->setColor(SparseArrayNode::Black); executed 6 times by 1 test: w->right->setColor(SparseArrayNode::Black); Executed by:
| 6 | ||||||||||||||||||
229 | rotateLeft(x_parent); | - | ||||||||||||||||||
230 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||
231 | } | - | ||||||||||||||||||
232 | } else { | - | ||||||||||||||||||
233 | SparseArrayNode *w = x_parent->left; | - | ||||||||||||||||||
234 | if (w->color() == SparseArrayNode::Red
| 0-52 | ||||||||||||||||||
235 | w->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
236 | x_parent->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
237 | rotateRight(x_parent); | - | ||||||||||||||||||
238 | w = x_parent->left; | - | ||||||||||||||||||
239 | } never executed: end of block | 0 | ||||||||||||||||||
240 | if ((w->right == nullptr
| 0-52 | ||||||||||||||||||
241 | (w->left == nullptr
| 0-52 | ||||||||||||||||||
242 | w->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
243 | x = x_parent; | - | ||||||||||||||||||
244 | x_parent = x_parent->parent(); | - | ||||||||||||||||||
245 | } executed 52 times by 1 test: else {end of block Executed by:
| 52 | ||||||||||||||||||
246 | if (w->left == nullptr
| 0 | ||||||||||||||||||
247 | if (w->right
| 0 | ||||||||||||||||||
248 | w->right->setColor(SparseArrayNode::Black); never executed: w->right->setColor(SparseArrayNode::Black); | 0 | ||||||||||||||||||
249 | w->setColor(SparseArrayNode::Red); | - | ||||||||||||||||||
250 | rotateLeft(w); | - | ||||||||||||||||||
251 | w = x_parent->left; | - | ||||||||||||||||||
252 | } never executed: end of block | 0 | ||||||||||||||||||
253 | w->setColor(x_parent->color()); | - | ||||||||||||||||||
254 | x_parent->setColor(SparseArrayNode::Black); | - | ||||||||||||||||||
255 | if (w->left
| 0 | ||||||||||||||||||
256 | w->left->setColor(SparseArrayNode::Black); never executed: w->left->setColor(SparseArrayNode::Black); | 0 | ||||||||||||||||||
257 | rotateRight(x_parent); | - | ||||||||||||||||||
258 | break; never executed: break; | 0 | ||||||||||||||||||
259 | } | - | ||||||||||||||||||
260 | } | - | ||||||||||||||||||
261 | } | - | ||||||||||||||||||
262 | if (x
| 116-168 | ||||||||||||||||||
263 | x->setColor(SparseArrayNode::Black); executed 116 times by 2 tests: x->setColor(SparseArrayNode::Black); Executed by:
| 116 | ||||||||||||||||||
264 | } executed 284 times by 2 tests: end of block Executed by:
| 284 | ||||||||||||||||||
265 | free(y); | - | ||||||||||||||||||
266 | --numEntries; | - | ||||||||||||||||||
267 | } executed 601 times by 2 tests: end of block Executed by:
| 601 | ||||||||||||||||||
268 | - | |||||||||||||||||||
269 | void SparseArray::recalcMostLeftNode() | - | ||||||||||||||||||
270 | { | - | ||||||||||||||||||
271 | mostLeftNode = &header; | - | ||||||||||||||||||
272 | while (mostLeftNode->left
| 0 | ||||||||||||||||||
273 | mostLeftNode = mostLeftNode->left; never executed: mostLeftNode = mostLeftNode->left; | 0 | ||||||||||||||||||
274 | } never executed: end of block | 0 | ||||||||||||||||||
275 | - | |||||||||||||||||||
276 | static inline int qMapAlignmentThreshold() | - | ||||||||||||||||||
277 | { | - | ||||||||||||||||||
278 | - | |||||||||||||||||||
279 | - | |||||||||||||||||||
280 | - | |||||||||||||||||||
281 | return executed 11918 times by 2 tests: 2 * sizeof(void*);return 2 * sizeof(void*); Executed by:
executed 11918 times by 2 tests: return 2 * sizeof(void*); Executed by:
| 11918 | ||||||||||||||||||
282 | } | - | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | static inline void *qMapAllocate(int alloc, int alignment) | - | ||||||||||||||||||
285 | { | - | ||||||||||||||||||
286 | return executed 6243 times by 2 tests: alignment > qMapAlignmentThreshold()return alignment > qMapAlignmentThreshold() ? qMallocAligned(alloc, alignment) : ::malloc(alloc); Executed by:
executed 6243 times by 2 tests: return alignment > qMapAlignmentThreshold() ? qMallocAligned(alloc, alignment) : ::malloc(alloc); Executed by:
| 6243 | ||||||||||||||||||
287 | ? qMallocAligned(alloc, alignment) executed 6243 times by 2 tests: return alignment > qMapAlignmentThreshold() ? qMallocAligned(alloc, alignment) : ::malloc(alloc); Executed by:
| 6243 | ||||||||||||||||||
288 | : ::malloc(alloc); executed 6243 times by 2 tests: return alignment > qMapAlignmentThreshold() ? qMallocAligned(alloc, alignment) : ::malloc(alloc); Executed by:
| 6243 | ||||||||||||||||||
289 | } | - | ||||||||||||||||||
290 | - | |||||||||||||||||||
291 | static inline void qMapDeallocate(SparseArrayNode *node, int alignment) | - | ||||||||||||||||||
292 | { | - | ||||||||||||||||||
293 | if (alignment > qMapAlignmentThreshold()
| 0-5673 | ||||||||||||||||||
294 | qFreeAligned(node); never executed: qFreeAligned(node); | 0 | ||||||||||||||||||
295 | else | - | ||||||||||||||||||
296 | :: executed 5673 times by 2 tests: free(node);::free(node); Executed by:
executed 5673 times by 2 tests: ::free(node); Executed by:
| 5673 | ||||||||||||||||||
297 | } | - | ||||||||||||||||||
298 | - | |||||||||||||||||||
299 | SparseArrayNode *SparseArray::createNode(uint sl, SparseArrayNode *parent, bool left) | - | ||||||||||||||||||
300 | { | - | ||||||||||||||||||
301 | SparseArrayNode *node = static_cast<SparseArrayNode *>(qMapAllocate(sizeof(SparseArrayNode), alignof(SparseArrayNode))); | - | ||||||||||||||||||
302 | do {if (!(node)
never executed: } while (false);qt_check_pointer(__FILE__,363); | 0-6261 | ||||||||||||||||||
303 | - | |||||||||||||||||||
304 | node->p = (quintptr)parent; | - | ||||||||||||||||||
305 | node->left = nullptr; | - | ||||||||||||||||||
306 | node->right = nullptr; | - | ||||||||||||||||||
307 | node->size_left = sl; | - | ||||||||||||||||||
308 | node->value = | - | ||||||||||||||||||
309 | (0x7fffffff * 2U + 1U) | - | ||||||||||||||||||
310 | ; | - | ||||||||||||||||||
311 | ++numEntries; | - | ||||||||||||||||||
312 | - | |||||||||||||||||||
313 | if (parent
| 0-6265 | ||||||||||||||||||
314 | if (left
| 2596-3668 | ||||||||||||||||||
315 | parent->left = node; | - | ||||||||||||||||||
316 | if (parent == mostLeftNode
| 220-3445 | ||||||||||||||||||
317 | mostLeftNode = node; executed 3441 times by 2 tests: mostLeftNode = node; Executed by:
| 3441 | ||||||||||||||||||
318 | } executed 3670 times by 2 tests: else {end of block Executed by:
| 3670 | ||||||||||||||||||
319 | parent->right = node; | - | ||||||||||||||||||
320 | } executed 2595 times by 2 tests: end of block Executed by:
| 2595 | ||||||||||||||||||
321 | node->setParent(parent); | - | ||||||||||||||||||
322 | rebalance(node); | - | ||||||||||||||||||
323 | } executed 6254 times by 2 tests: end of block Executed by:
| 6254 | ||||||||||||||||||
324 | return executed 6260 times by 2 tests: node;return node; Executed by:
executed 6260 times by 2 tests: return node; Executed by:
| 6260 | ||||||||||||||||||
325 | } | - | ||||||||||||||||||
326 | - | |||||||||||||||||||
327 | void SparseArray::freeTree(SparseArrayNode *root, int alignment) | - | ||||||||||||||||||
328 | { | - | ||||||||||||||||||
329 | if (root->left
| 1376-4298 | ||||||||||||||||||
330 | freeTree(root->left, alignment); executed 1376 times by 2 tests: freeTree(root->left, alignment); Executed by:
| 1376 | ||||||||||||||||||
331 | if (root->right
| 1354-4319 | ||||||||||||||||||
332 | freeTree(root->right, alignment); executed 1354 times by 2 tests: freeTree(root->right, alignment); Executed by:
| 1354 | ||||||||||||||||||
333 | qMapDeallocate(root, alignment); | - | ||||||||||||||||||
334 | } executed 5674 times by 2 tests: end of block Executed by:
| 5674 | ||||||||||||||||||
335 | - | |||||||||||||||||||
336 | SparseArray::SparseArray() | - | ||||||||||||||||||
337 | : numEntries(0) | - | ||||||||||||||||||
338 | { | - | ||||||||||||||||||
339 | freeList = Encode(-1); | - | ||||||||||||||||||
340 | header.p = 0; | - | ||||||||||||||||||
341 | header.left = nullptr; | - | ||||||||||||||||||
342 | header.right = nullptr; | - | ||||||||||||||||||
343 | mostLeftNode = &header; | - | ||||||||||||||||||
344 | } executed 3171 times by 2 tests: end of block Executed by:
| 3171 | ||||||||||||||||||
345 | - | |||||||||||||||||||
346 | SparseArray::SparseArray(const SparseArray &other) | - | ||||||||||||||||||
347 | { | - | ||||||||||||||||||
348 | header.p = 0; | - | ||||||||||||||||||
349 | header.right = nullptr; | - | ||||||||||||||||||
350 | if (other.header.left
| 0 | ||||||||||||||||||
351 | header.left = other.header.left->copy(this); | - | ||||||||||||||||||
352 | header.left->setParent(&header); | - | ||||||||||||||||||
353 | recalcMostLeftNode(); | - | ||||||||||||||||||
354 | } never executed: end of block | 0 | ||||||||||||||||||
355 | freeList = other.freeList; | - | ||||||||||||||||||
356 | } never executed: end of block | 0 | ||||||||||||||||||
357 | - | |||||||||||||||||||
358 | SparseArrayNode *SparseArray::insert(uint akey) | - | ||||||||||||||||||
359 | { | - | ||||||||||||||||||
360 | SparseArrayNode *n = root(); | - | ||||||||||||||||||
361 | SparseArrayNode *y = end(); | - | ||||||||||||||||||
362 | bool left = true; | - | ||||||||||||||||||
363 | uint s = akey; | - | ||||||||||||||||||
364 | while (n
| 6235-12552 | ||||||||||||||||||
365 | y = n; | - | ||||||||||||||||||
366 | if (s == n->size_left
| 5093-7458 | ||||||||||||||||||
367 | return executed 5095 times by 1 test: n;return n; Executed by:
executed 5095 times by 1 test: return n; Executed by:
| 5095 | ||||||||||||||||||
368 | } else if (s < n->size_left
| 1693-5768 | ||||||||||||||||||
369 | left = true; | - | ||||||||||||||||||
370 | n = n->left; | - | ||||||||||||||||||
371 | } executed 1693 times by 2 tests: else {end of block Executed by:
| 1693 | ||||||||||||||||||
372 | left = false; | - | ||||||||||||||||||
373 | s -= n->size_left; | - | ||||||||||||||||||
374 | n = n->right; | - | ||||||||||||||||||
375 | } executed 5768 times by 2 tests: end of block Executed by:
| 5768 | ||||||||||||||||||
376 | } | - | ||||||||||||||||||
377 | - | |||||||||||||||||||
378 | return executed 6247 times by 2 tests: createNode(s, y, left);return createNode(s, y, left); Executed by:
executed 6247 times by 2 tests: return createNode(s, y, left); Executed by:
| 6247 | ||||||||||||||||||
379 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |