Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | namespace QtPrivate { | - |
7 | | - |
8 | ResultIteratorBase::ResultIteratorBase() | - |
9 | : mapIterator(QMap<int, ResultItem>::const_iterator()), m_vectorIndex(0) { } | 0 |
10 | ResultIteratorBase::ResultIteratorBase(QMap<int, ResultItem>::const_iterator _mapIterator, int _vectorIndex) | - |
11 | : mapIterator(_mapIterator), m_vectorIndex(_vectorIndex) { } executed: } Execution Count:1318475 | 1318475 |
12 | | - |
13 | int ResultIteratorBase::vectorIndex() const { return m_vectorIndex; } never executed: return m_vectorIndex; | 0 |
14 | int ResultIteratorBase::resultIndex() const { return mapIterator.key() + m_vectorIndex; } executed: return mapIterator.key() + m_vectorIndex; Execution Count:37 | 37 |
15 | | - |
16 | ResultIteratorBase ResultIteratorBase::operator++() | - |
17 | { | - |
18 | if (canIncrementVectorIndex()) { evaluated: canIncrementVectorIndex() yes Evaluation Count:15 | yes Evaluation Count:574 |
| 15-574 |
19 | ++m_vectorIndex; | - |
20 | } else { executed: } Execution Count:15 | 15 |
21 | ++mapIterator; | - |
22 | m_vectorIndex = 0; | - |
23 | } executed: } Execution Count:574 | 574 |
24 | return *this; executed: return *this; Execution Count:589 | 589 |
25 | } | - |
26 | | - |
27 | int ResultIteratorBase::batchSize() const | - |
28 | { | - |
29 | return mapIterator.value().count(); executed: return mapIterator.value().count(); Execution Count:261469 | 261469 |
30 | } | - |
31 | | - |
32 | void ResultIteratorBase::batchedAdvance() | - |
33 | { | - |
34 | ++mapIterator; | - |
35 | m_vectorIndex = 0; | - |
36 | } executed: } Execution Count:9 | 9 |
37 | | - |
38 | bool ResultIteratorBase::operator==(const ResultIteratorBase &other) const | - |
39 | { | - |
40 | return (mapIterator == other.mapIterator && m_vectorIndex == other.m_vectorIndex); executed: return (mapIterator == other.mapIterator && m_vectorIndex == other.m_vectorIndex); Execution Count:536586 | 536586 |
41 | } | - |
42 | | - |
43 | bool ResultIteratorBase::operator!=(const ResultIteratorBase &other) const | - |
44 | { | - |
45 | return !operator==(other); executed: return !operator==(other); Execution Count:536020 | 536020 |
46 | } | - |
47 | | - |
48 | bool ResultIteratorBase::isVector() const | - |
49 | { | - |
50 | return mapIterator.value().isVector(); never executed: return mapIterator.value().isVector(); | 0 |
51 | } | - |
52 | | - |
53 | bool ResultIteratorBase::canIncrementVectorIndex() const | - |
54 | { | - |
55 | return (m_vectorIndex + 1 < mapIterator.value().m_count); executed: return (m_vectorIndex + 1 < mapIterator.value().m_count); Execution Count:589 | 589 |
56 | } | - |
57 | | - |
58 | ResultStoreBase::ResultStoreBase() | - |
59 | : insertIndex(0), resultCount(0), m_filterMode(false), filteredResults(0) { } executed: } Execution Count:583050 | 583050 |
60 | | - |
61 | void ResultStoreBase::setFilterMode(bool enable) | - |
62 | { | - |
63 | m_filterMode = enable; | - |
64 | } executed: } Execution Count:50 | 50 |
65 | | - |
66 | bool ResultStoreBase::filterMode() const | - |
67 | { | - |
68 | return m_filterMode; executed: return m_filterMode; Execution Count:263712 | 263712 |
69 | } | - |
70 | | - |
71 | void ResultStoreBase::syncResultCount() | - |
72 | { | - |
73 | ResultIteratorBase it = resultAt(resultCount); | - |
74 | while (it != end()) { evaluated: it != end() yes Evaluation Count:261839 | yes Evaluation Count:260700 |
| 260700-261839 |
75 | resultCount += it.batchSize(); | - |
76 | it = resultAt(resultCount); | - |
77 | } executed: } Execution Count:261126 | 261126 |
78 | } executed: } Execution Count:260403 | 260403 |
79 | | - |
80 | void ResultStoreBase::insertResultItemIfValid(int index, ResultItem &resultItem) | - |
81 | { | - |
82 | if (resultItem.isValid()) { evaluated: resultItem.isValid() yes Evaluation Count:262382 | yes Evaluation Count:677 |
| 677-262382 |
83 | m_results[index] = resultItem; | - |
84 | syncResultCount(); | - |
85 | } else { executed: } Execution Count:260531 | 260531 |
86 | filteredResults += resultItem.count(); | - |
87 | } executed: } Execution Count:677 | 677 |
88 | } | - |
89 | | - |
90 | int ResultStoreBase::insertResultItem(int index, ResultItem &resultItem) | - |
91 | { | - |
92 | int storeIndex; | - |
93 | if (m_filterMode && index != -1 && index > insertIndex) { evaluated: m_filterMode yes Evaluation Count:1388 | yes Evaluation Count:263101 |
partially evaluated: index != -1 yes Evaluation Count:1388 | no Evaluation Count:0 |
evaluated: index > insertIndex yes Evaluation Count:1265 | yes Evaluation Count:123 |
| 0-263101 |
94 | pendingResults[index] = resultItem; | - |
95 | storeIndex = index; | - |
96 | } else { executed: } Execution Count:1265 | 1265 |
97 | storeIndex = updateInsertIndex(index, resultItem.count()); | - |
98 | insertResultItemIfValid(storeIndex - filteredResults, resultItem); | - |
99 | } executed: } Execution Count:260084 | 260084 |
100 | syncPendingResults(); | - |
101 | return storeIndex; executed: return storeIndex; Execution Count:264885 | 264885 |
102 | } | - |
103 | | - |
104 | void ResultStoreBase::syncPendingResults() | - |
105 | { | - |
106 | | - |
107 | QMap<int, ResultItem>::iterator it = pendingResults.begin(); | - |
108 | while (it != pendingResults.end()) { evaluated: it != pendingResults.end() yes Evaluation Count:2426 | yes Evaluation Count:263891 |
| 2426-263891 |
109 | int index = it.key(); | - |
110 | if (index != resultCount + filteredResults) evaluated: index != resultCount + filteredResults yes Evaluation Count:1161 | yes Evaluation Count:1265 |
| 1161-1265 |
111 | break; executed: break; Execution Count:1161 | 1161 |
112 | | - |
113 | ResultItem result = it.value(); | - |
114 | insertResultItemIfValid(index - filteredResults, result); | - |
115 | pendingResults.erase(it); | - |
116 | it = pendingResults.begin(); | - |
117 | } executed: } Execution Count:1265 | 1265 |
118 | } executed: } Execution Count:264885 | 264885 |
119 | | - |
120 | int ResultStoreBase::addResult(int index, const void *result) | - |
121 | { | - |
122 | ResultItem resultItem(result, 0); | - |
123 | return insertResultItem(index, resultItem); executed: return insertResultItem(index, resultItem); Execution Count:263660 | 263660 |
124 | } | - |
125 | | - |
126 | int ResultStoreBase::addResults(int index, const void *results, int vectorSize, int totalCount) | - |
127 | { | - |
128 | if (m_filterMode == false || vectorSize == totalCount) { evaluated: m_filterMode == false yes Evaluation Count:199 | yes Evaluation Count:754 |
evaluated: vectorSize == totalCount yes Evaluation Count:124 | yes Evaluation Count:630 |
| 124-754 |
129 | ResultItem resultItem(results, vectorSize); | - |
130 | return insertResultItem(index, resultItem); executed: return insertResultItem(index, resultItem); Execution Count:323 | 323 |
131 | } else { | - |
132 | if (vectorSize > 0) { evaluated: vectorSize > 0 yes Evaluation Count:512 | yes Evaluation Count:118 |
| 118-512 |
133 | ResultItem filteredIn(results, vectorSize); | - |
134 | insertResultItem(index, filteredIn); | - |
135 | } executed: } Execution Count:512 | 512 |
136 | ResultItem filteredAway(0, totalCount - vectorSize); | - |
137 | return insertResultItem(index + vectorSize, filteredAway); executed: return insertResultItem(index + vectorSize, filteredAway); Execution Count:630 | 630 |
138 | } | - |
139 | } | - |
140 | | - |
141 | ResultIteratorBase ResultStoreBase::begin() const | - |
142 | { | - |
143 | return ResultIteratorBase(m_results.begin()); executed: return ResultIteratorBase(m_results.begin()); Execution Count:147 | 147 |
144 | } | - |
145 | | - |
146 | ResultIteratorBase ResultStoreBase::end() const | - |
147 | { | - |
148 | return ResultIteratorBase(m_results.end()); executed: return ResultIteratorBase(m_results.end()); Execution Count:536683 | 536683 |
149 | } | - |
150 | | - |
151 | bool ResultStoreBase::hasNextResult() const | - |
152 | { | - |
153 | return begin() != end(); never executed: return begin() != end(); | 0 |
154 | } | - |
155 | | - |
156 | ResultIteratorBase ResultStoreBase::resultAt(int index) const | - |
157 | { | - |
158 | if (m_results.isEmpty()) evaluated: m_results.isEmpty() yes Evaluation Count:399 | yes Evaluation Count:805378 |
| 399-805378 |
159 | return ResultIteratorBase(m_results.end()); executed: return ResultIteratorBase(m_results.end()); Execution Count:399 | 399 |
160 | QMap<int, ResultItem>::const_iterator it = m_results.lowerBound(index); | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | if (it == m_results.end()) { evaluated: it == m_results.end() yes Evaluation Count:260364 | yes Evaluation Count:555887 |
| 260364-555887 |
166 | --it; | - |
167 | if (it.value().isVector() == false) { evaluated: it.value().isVector() == false yes Evaluation Count:259128 | yes Evaluation Count:1070 |
| 1070-259128 |
168 | return ResultIteratorBase(m_results.end()); executed: return ResultIteratorBase(m_results.end()); Execution Count:259193 | 259193 |
169 | } | - |
170 | } else { executed: } Execution Count:1070 | 1070 |
171 | if (it.key() > index) { evaluated: it.key() > index yes Evaluation Count:30113 | yes Evaluation Count:526183 |
| 30113-526183 |
172 | if (it == m_results.begin()) evaluated: it == m_results.begin() yes Evaluation Count:39 | yes Evaluation Count:30074 |
| 39-30074 |
173 | return ResultIteratorBase(m_results.end()); executed: return ResultIteratorBase(m_results.end()); Execution Count:39 | 39 |
174 | --it; | - |
175 | } executed: } Execution Count:30074 | 30074 |
176 | } executed: } Execution Count:555953 | 555953 |
177 | | - |
178 | const int vectorIndex = index - it.key(); | - |
179 | | - |
180 | if (vectorIndex >= it.value().count()) evaluated: vectorIndex >= it.value().count() yes Evaluation Count:2174 | yes Evaluation Count:554265 |
| 2174-554265 |
181 | return ResultIteratorBase(m_results.end()); executed: return ResultIteratorBase(m_results.end()); Execution Count:2174 | 2174 |
182 | else if (it.value().isVector() == false && vectorIndex != 0) evaluated: it.value().isVector() == false yes Evaluation Count:521479 | yes Evaluation Count:33076 |
partially evaluated: vectorIndex != 0 no Evaluation Count:0 | yes Evaluation Count:521985 |
| 0-521985 |
183 | return ResultIteratorBase(m_results.end()); never executed: return ResultIteratorBase(m_results.end()); | 0 |
184 | return ResultIteratorBase(it, vectorIndex); executed: return ResultIteratorBase(it, vectorIndex); Execution Count:554036 | 554036 |
185 | } | - |
186 | | - |
187 | bool ResultStoreBase::contains(int index) const | - |
188 | { | - |
189 | return (resultAt(index) != end()); executed: return (resultAt(index) != end()); Execution Count:19045 | 19045 |
190 | } | - |
191 | | - |
192 | int ResultStoreBase::count() const | - |
193 | { | - |
194 | return resultCount; executed: return resultCount; Execution Count:5560 | 5560 |
195 | } | - |
196 | | - |
197 | | - |
198 | | - |
199 | int ResultStoreBase::updateInsertIndex(int index, int _count) | - |
200 | { | - |
201 | if (index == -1) { evaluated: index == -1 yes Evaluation Count:260864 | yes Evaluation Count:1969 |
| 1969-260864 |
202 | index = insertIndex; | - |
203 | insertIndex += _count; | - |
204 | } else { executed: } Execution Count:260703 | 260703 |
205 | insertIndex = qMax(index + _count, insertIndex); | - |
206 | } executed: } Execution Count:1969 | 1969 |
207 | return index; executed: return index; Execution Count:262701 | 262701 |
208 | } | - |
209 | | - |
210 | } | - |
211 | | - |
212 | | - |
213 | | - |
| | |