OpenCoverage

qv4sparsearray_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4sparsearray_p.h
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3namespace QV4 {-
4-
5struct SparseArray;-
6-
7struct SparseArrayNode-
8{-
9 quintptr p;-
10 SparseArrayNode *left;-
11 SparseArrayNode *right;-
12 uint size_left;-
13 uint value;-
14-
15 enum Color { Red = 0, Black = 1 };-
16 enum { Mask = 3 };-
17-
18 const SparseArrayNode *nextNode() const;-
19 SparseArrayNode *nextNode() { return
executed 1549 times by 2 tests: return const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->nextNode());
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->nextNode());
executed 1549 times by 2 tests: return const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->nextNode());
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
}
1549
20 const SparseArrayNode *previousNode() const;-
21 SparseArrayNode *previousNode() { return
executed 362 times by 1 test: return const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->previousNode());
Executed by:
  • tst_ecmascripttests
const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->previousNode());
executed 362 times by 1 test: return const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->previousNode());
Executed by:
  • tst_ecmascripttests
}
362
22-
23 Color color() const { return
executed 5531 times by 2 tests: return Color(p & 1);
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
Color(p & 1);
executed 5531 times by 2 tests: return Color(p & 1);
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
}
5531
24 void setColor(Color c) { if (c == Black
c == BlackDescription
TRUEevaluated 8309 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 7821 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
) p |= Black;
executed 8308 times by 2 tests: p |= Black;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
else p &= ~Black;
executed 7823 times by 2 tests: p &= ~Black;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
}
7821-8309
25 SparseArrayNode *parent() const { return
executed 28724 times by 2 tests: return reinterpret_cast<SparseArrayNode *>(p & ~Mask);
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
reinterpret_cast<SparseArrayNode *>(p & ~Mask);
executed 28724 times by 2 tests: return reinterpret_cast<SparseArrayNode *>(p & ~Mask);
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
}
28724
26 void setParent(SparseArrayNode *pp) { p = (p & Mask) | quintptr(pp); }
executed 8948 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
8948
27-
28 uint key() const {-
29 uint k = size_left;-
30 const SparseArrayNode *n = this;-
31 while (SparseArrayNode *p = n->parent()
SparseArrayNod... = n->parent()Description
TRUEevaluated 1459 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 1004 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
) {
1004-1459
32 if (p
pDescription
TRUEevaluated 1459 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEnever evaluated
&& p->right == n
p->right == nDescription
TRUEevaluated 240 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 1219 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
)
0-1459
33 k += p->size_left;
executed 240 times by 2 tests: k += p->size_left;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
240
34 n = p;-
35 }
executed 1460 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
1460
36 return
executed 1005 times by 2 tests: return k;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
k;
executed 1005 times by 2 tests: return k;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
1005
37 }-
38-
39 SparseArrayNode *copy(SparseArray *d) const;-
40-
41 SparseArrayNode *lowerBound(uint key);-
42 SparseArrayNode *upperBound(uint key);-
43};-
44-
45-
46inline SparseArrayNode *SparseArrayNode::lowerBound(uint akey)-
47{-
48 SparseArrayNode *n = this;-
49 SparseArrayNode *last = nullptr;-
50 while (n
nDescription
TRUEevaluated 352 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 158 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
158-352
51 if (akey <= n->size_left
akey <= n->size_leftDescription
TRUEevaluated 170 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 182 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
170-182
52 last = n;-
53 n = n->left;-
54 }
executed 170 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
else {
170
55 akey -= n->size_left;-
56 n = n->right;-
57 }
executed 182 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
182
58 }-
59 return
executed 158 times by 1 test: return last;
Executed by:
  • tst_ecmascripttests
last;
executed 158 times by 1 test: return last;
Executed by:
  • tst_ecmascripttests
158
60}-
61-
62-
63inline SparseArrayNode *SparseArrayNode::upperBound(uint akey)-
64{-
65 SparseArrayNode *n = this;-
66 SparseArrayNode *last = nullptr;-
67 while (n
nDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
68 if (akey < n->size_left
akey < n->size_leftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
69 last = n;-
70 n = n->left;-
71 }
never executed: end of block
else {
0
72 akey -= n->size_left;-
73 n = n->right;-
74 }
never executed: end of block
0
75 }-
76 return
never executed: return last;
last;
never executed: return last;
0
77}-
78-
79-
80-
81struct __attribute__((visibility("default"))) SparseArray-
82{-
83 SparseArray();-
84 ~SparseArray() {-
85 if (root()
root()Description
TRUEevaluated 2944 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 262 times by 1 test
Evaluated by:
  • tst_ecmascripttests
)
262-2944
86 freeTree(header.left, alignof(SparseArrayNode));
executed 2944 times by 2 tests: freeTree(header.left, alignof(SparseArrayNode));
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
2944
87 }
executed 3206 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
3206
88-
89 SparseArray(const SparseArray &other);-
90-
91 Value freeList;-
92private:-
93 SparseArray &operator=(const SparseArray &other);-
94-
95 int numEntries;-
96 SparseArrayNode header;-
97 SparseArrayNode *mostLeftNode;-
98-
99 void rotateLeft(SparseArrayNode *x);-
100 void rotateRight(SparseArrayNode *x);-
101 void rebalance(SparseArrayNode *x);-
102 void recalcMostLeftNode();-
103-
104 SparseArrayNode *root() const { return
executed 27376298 times by 2 tests: return header.left;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
header.left;
executed 27376298 times by 2 tests: return header.left;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
}
27376298
105-
106 void deleteNode(SparseArrayNode *z);-
107-
108-
109public:-
110 SparseArrayNode *createNode(uint sl, SparseArrayNode *parent, bool left);-
111 void freeTree(SparseArrayNode *root, int alignment);-
112-
113 SparseArrayNode *findNode(uint akey) const;-
114-
115 uint nEntries() const { return
never executed: return numEntries;
numEntries;
never executed: return numEntries;
}
0
116-
117 uint pop_front();-
118 void push_front(uint at);-
119 uint pop_back(uint len);-
120 void push_back(uint at, uint len);-
121-
122 QList<int> keys() const;-
123-
124 const SparseArrayNode *end() const { return
never executed: return &header;
&header;
never executed: return &header;
}
0
125 SparseArrayNode *end() { return
executed 13756 times by 2 tests: return &header;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
&header;
executed 13756 times by 2 tests: return &header;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
}
13756
126 const SparseArrayNode *begin() const { if (root()
root()Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return mostLeftNode;
mostLeftNode;
never executed: return mostLeftNode;
return
never executed: return end();
end();
never executed: return end();
}
0
127 SparseArrayNode *begin() { if (root()
root()Description
TRUEevaluated 613 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) return
executed 613 times by 2 tests: return mostLeftNode;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
mostLeftNode;
executed 613 times by 2 tests: return mostLeftNode;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
return
executed 38 times by 1 test: return end();
Executed by:
  • tst_ecmascripttests
end();
executed 38 times by 1 test: return end();
Executed by:
  • tst_ecmascripttests
}
38-613
128-
129 SparseArrayNode *erase(SparseArrayNode *n);-
130-
131 SparseArrayNode *lowerBound(uint key);-
132 const SparseArrayNode *lowerBound(uint key) const;-
133 SparseArrayNode *upperBound(uint key);-
134 const SparseArrayNode *upperBound(uint key) const;-
135 SparseArrayNode *insert(uint akey);-
136-
137-
138 typedef uint key_type;-
139 typedef int mapped_type;-
140 typedef qptrdiff difference_type;-
141 typedef int size_type;-
142-
143-
144-
145-
146};-
147-
148inline SparseArrayNode *SparseArray::findNode(uint akey) const-
149{-
150 SparseArrayNode *n = root();-
151-
152 while (n
nDescription
TRUEevaluated 101893349 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 27363093 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
) {
27363093-101893349
153 if (akey == n->size_left
akey == n->size_leftDescription
TRUEevaluated 23275 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 101877363 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
) {
23275-101877363
154 return
executed 23278 times by 2 tests: return n;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
n;
executed 23278 times by 2 tests: return n;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
23278
155 } else if (akey < n->size_left
akey < n->size_leftDescription
TRUEevaluated 27676901 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
FALSEevaluated 74260435 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
) {
27676901-74260435
156 n = n->left;-
157 }
executed 27679471 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
else {
27679471
158 akey -= n->size_left;-
159 n = n->right;-
160 }
executed 74263779 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
74263779
161 }-
162-
163 return
executed 27369006 times by 2 tests: return nullptr;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
nullptr;
executed 27369006 times by 2 tests: return nullptr;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
27369006
164}-
165-
166inline uint SparseArray::pop_front()-
167{-
168 uint idx = -
169 (0x7fffffff * 2U + 1U) -
170 ;-
171-
172 SparseArrayNode *n = findNode(0);-
173 if (n
nDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
174 idx = n->value;-
175 deleteNode(n);-
176-
177 SparseArrayNode *n = root();-
178 while (n
nDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
179 n->size_left -= 1;-
180 n = n->left;-
181 }
never executed: end of block
0
182 }
never executed: end of block
0
183 return
never executed: return idx;
idx;
never executed: return idx;
0
184}-
185-
186inline void SparseArray::push_front(uint value)-
187{-
188-
189 SparseArrayNode *n = root();-
190 while (n
nDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
191 n->size_left += 1;-
192 n = n->left;-
193 }
never executed: end of block
0
194 n = insert(0);-
195 n->value = value;-
196}
never executed: end of block
0
197-
198inline uint SparseArray::pop_back(uint len)-
199{-
200 uint idx = -
201 (0x7fffffff * 2U + 1U)-
202 ;-
203 if (!len
!lenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
204 return
never executed: return idx;
idx;
never executed: return idx;
0
205-
206 SparseArrayNode *n = findNode(len - 1);-
207 if (n
nDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
208 idx = n->value;-
209 deleteNode(n);-
210 }
never executed: end of block
0
211 return
never executed: return idx;
idx;
never executed: return idx;
0
212}-
213-
214inline void SparseArray::push_back(uint index, uint len)-
215{-
216 SparseArrayNode *n = insert(len);-
217 n->value = index;-
218}
never executed: end of block
0
219inline SparseArrayNode *SparseArray::erase(SparseArrayNode *n)-
220{-
221 if (n == end()
n == end()Description
TRUEnever evaluated
FALSEevaluated 600 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
)
0-600
222 return
never executed: return n;
n;
never executed: return n;
0
223-
224 SparseArrayNode *next = n->nextNode();-
225 deleteNode(n);-
226 return
executed 599 times by 2 tests: return next;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
next;
executed 599 times by 2 tests: return next;
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
599
227}-
228-
229inline QList<int> SparseArray::keys() const-
230{-
231 QList<int> res;-
232 res.reserve(numEntries);-
233 SparseArrayNode *n = mostLeftNode;-
234 while (n != end()
n != end()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
235 res.append(n->key());-
236 n = n->nextNode();-
237 }
never executed: end of block
0
238 return
never executed: return res;
res;
never executed: return res;
0
239}-
240-
241inline const SparseArrayNode *SparseArray::lowerBound(uint akey) const-
242{-
243 const SparseArrayNode *lb = root()->lowerBound(akey);-
244 if (!lb
!lbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
245 lb = end();
never executed: lb = end();
0
246 return
never executed: return lb;
lb;
never executed: return lb;
0
247}-
248-
249-
250inline SparseArrayNode *SparseArray::lowerBound(uint akey)-
251{-
252 SparseArrayNode *lb = root()->lowerBound(akey);-
253 if (!lb
!lbDescription
TRUEnever evaluated
FALSEevaluated 158 times by 1 test
Evaluated by:
  • tst_ecmascripttests
)
0-158
254 lb = end();
never executed: lb = end();
0
255 return
executed 158 times by 1 test: return lb;
Executed by:
  • tst_ecmascripttests
lb;
executed 158 times by 1 test: return lb;
Executed by:
  • tst_ecmascripttests
158
256}-
257-
258-
259inline const SparseArrayNode *SparseArray::upperBound(uint akey) const-
260{-
261 const SparseArrayNode *ub = root()->upperBound(akey);-
262 if (!ub
!ubDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
263 ub = end();
never executed: ub = end();
0
264 return
never executed: return ub;
ub;
never executed: return ub;
0
265}-
266-
267-
268inline SparseArrayNode *SparseArray::upperBound(uint akey)-
269{-
270 SparseArrayNode *ub = root()->upperBound(akey);-
271 if (!ub
!ubDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
272 ub = end();
never executed: ub = end();
0
273 return
never executed: return ub;
ub;
never executed: return ub;
0
274}-
275-
276}-
277-
278-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0