Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4estable.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | using namespace QV4; | - | ||||||||||||
3 | ESTable::ESTable() | - | ||||||||||||
4 | : m_capacity(8) | - | ||||||||||||
5 | { | - | ||||||||||||
6 | m_keys = (Value*)malloc(m_capacity * sizeof(Value)); | - | ||||||||||||
7 | m_values = (Value*)malloc(m_capacity * sizeof(Value)); | - | ||||||||||||
8 | memset(m_keys, 0, m_capacity); | - | ||||||||||||
9 | memset(m_values, 0, m_capacity); | - | ||||||||||||
10 | } executed 1188 times by 1 test: end of block Executed by:
| 1188 | ||||||||||||
11 | - | |||||||||||||
12 | ESTable::~ESTable() | - | ||||||||||||
13 | { | - | ||||||||||||
14 | free(m_keys); | - | ||||||||||||
15 | free(m_values); | - | ||||||||||||
16 | m_size = 0; | - | ||||||||||||
17 | m_capacity = 0; | - | ||||||||||||
18 | m_keys = nullptr; | - | ||||||||||||
19 | m_values = nullptr; | - | ||||||||||||
20 | } executed 1198 times by 1 test: end of block Executed by:
| 1198 | ||||||||||||
21 | - | |||||||||||||
22 | void ESTable::markObjects(MarkStack *s) | - | ||||||||||||
23 | { | - | ||||||||||||
24 | for (uint i = 0; i < m_size
| 0 | ||||||||||||
25 | m_keys[i].mark(s); | - | ||||||||||||
26 | m_values[i].mark(s); | - | ||||||||||||
27 | } never executed: end of block | 0 | ||||||||||||
28 | } never executed: end of block | 0 | ||||||||||||
29 | - | |||||||||||||
30 | - | |||||||||||||
31 | - | |||||||||||||
32 | void ESTable::clear() | - | ||||||||||||
33 | { | - | ||||||||||||
34 | m_size = 0; | - | ||||||||||||
35 | } executed 52 times by 1 test: end of block Executed by:
| 52 | ||||||||||||
36 | - | |||||||||||||
37 | - | |||||||||||||
38 | - | |||||||||||||
39 | void ESTable::set(const Value &key, const Value &value) | - | ||||||||||||
40 | { | - | ||||||||||||
41 | for (uint i = 0; i < m_size
| 901-1208 | ||||||||||||
42 | if (m_keys[i].sameValueZero(key)
| 44-1163 | ||||||||||||
43 | m_values[i] = value; | - | ||||||||||||
44 | return; executed 44 times by 1 test: return; Executed by:
| 44 | ||||||||||||
45 | } | - | ||||||||||||
46 | } executed 1163 times by 1 test: end of block Executed by:
| 1163 | ||||||||||||
47 | - | |||||||||||||
48 | if (m_capacity == m_size
| 4-898 | ||||||||||||
49 | uint oldCap = m_capacity; | - | ||||||||||||
50 | m_capacity *= 2; | - | ||||||||||||
51 | m_keys = (Value*)realloc(m_keys, m_capacity * sizeof(Value)); | - | ||||||||||||
52 | m_values = (Value*)realloc(m_values, m_capacity * sizeof(Value)); | - | ||||||||||||
53 | memset(m_keys + oldCap, 0, m_capacity - oldCap); | - | ||||||||||||
54 | memset(m_values + oldCap, 0, m_capacity - oldCap); | - | ||||||||||||
55 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
56 | - | |||||||||||||
57 | Value nk = key; | - | ||||||||||||
58 | if (nk.isDouble()
| 56-849 | ||||||||||||
59 | if (nk.doubleValue() == 0
| 0-32 | ||||||||||||
60 | nk = Primitive::fromDouble(+0); executed 24 times by 1 test: nk = Primitive::fromDouble(+0); Executed by:
| 24 | ||||||||||||
61 | } executed 56 times by 1 test: end of block Executed by:
| 56 | ||||||||||||
62 | - | |||||||||||||
63 | m_keys[m_size] = nk; | - | ||||||||||||
64 | m_values[m_size] = value; | - | ||||||||||||
65 | - | |||||||||||||
66 | m_size++; | - | ||||||||||||
67 | } executed 904 times by 1 test: end of block Executed by:
| 904 | ||||||||||||
68 | - | |||||||||||||
69 | - | |||||||||||||
70 | bool ESTable::has(const Value &key) const | - | ||||||||||||
71 | { | - | ||||||||||||
72 | for (uint i = 0; i < m_size
| 104-276 | ||||||||||||
73 | if (m_keys[i].sameValueZero(key)
| 95-180 | ||||||||||||
74 | return executed 95 times by 1 test: true;return true; Executed by:
executed 95 times by 1 test: return true; Executed by:
| 95 | ||||||||||||
75 | } executed 180 times by 1 test: end of block Executed by:
| 180 | ||||||||||||
76 | - | |||||||||||||
77 | return executed 104 times by 1 test: false;return false; Executed by:
executed 104 times by 1 test: return false; Executed by:
| 104 | ||||||||||||
78 | } | - | ||||||||||||
79 | - | |||||||||||||
80 | - | |||||||||||||
81 | - | |||||||||||||
82 | ReturnedValue ESTable::get(const Value &key, bool *hasValue) const | - | ||||||||||||
83 | { | - | ||||||||||||
84 | for (uint i = 0; i < m_size
| 12-180 | ||||||||||||
85 | if (m_keys[i].sameValueZero(key)
| 64-116 | ||||||||||||
86 | if (hasValue
| 0-64 | ||||||||||||
87 | * never executed: hasValue = true;*hasValue = true; never executed: *hasValue = true; | 0 | ||||||||||||
88 | return executed 64 times by 1 test: m_values[i].asReturnedValue();return m_values[i].asReturnedValue(); Executed by:
executed 64 times by 1 test: return m_values[i].asReturnedValue(); Executed by:
| 64 | ||||||||||||
89 | } | - | ||||||||||||
90 | } executed 116 times by 1 test: end of block Executed by:
| 116 | ||||||||||||
91 | - | |||||||||||||
92 | if (hasValue
| 0-12 | ||||||||||||
93 | * never executed: hasValue = false;*hasValue = false; never executed: *hasValue = false; | 0 | ||||||||||||
94 | return executed 12 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 12 times by 1 test: return Encode::undefined(); Executed by:
| 12 | ||||||||||||
95 | } | - | ||||||||||||
96 | - | |||||||||||||
97 | - | |||||||||||||
98 | bool ESTable::remove(const Value &key) | - | ||||||||||||
99 | { | - | ||||||||||||
100 | bool found = false; | - | ||||||||||||
101 | uint idx = 0; | - | ||||||||||||
102 | for (; idx < m_size
| 28-136 | ||||||||||||
103 | if (m_keys[idx].sameValueZero(key)
| 48-88 | ||||||||||||
104 | found = true; | - | ||||||||||||
105 | break; executed 88 times by 1 test: break; Executed by:
| 88 | ||||||||||||
106 | } | - | ||||||||||||
107 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||
108 | - | |||||||||||||
109 | if (found == true
| 28-88 | ||||||||||||
110 | memmove(m_keys + idx, m_keys + idx + 1, m_size - idx); | - | ||||||||||||
111 | memmove(m_values + idx, m_values + idx + 1, m_size - idx); | - | ||||||||||||
112 | m_size--; | - | ||||||||||||
113 | } executed 87 times by 1 test: end of block Executed by:
| 87 | ||||||||||||
114 | return executed 116 times by 1 test: found;return found; Executed by:
executed 116 times by 1 test: return found; Executed by:
| 116 | ||||||||||||
115 | } | - | ||||||||||||
116 | - | |||||||||||||
117 | - | |||||||||||||
118 | uint ESTable::size() const | - | ||||||||||||
119 | { | - | ||||||||||||
120 | return executed 836 times by 1 test: m_size;return m_size; Executed by:
executed 836 times by 1 test: return m_size; Executed by:
| 836 | ||||||||||||
121 | } | - | ||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | void ESTable::iterate(uint idx, Value *key, Value *value) | - | ||||||||||||
126 | { | - | ||||||||||||
127 | ((idx < m_size) ? static_cast<void>(0) : qt_assert("idx < m_size", __FILE__, 175)); | - | ||||||||||||
128 | ((key) ? static_cast<void>(0) : qt_assert("key", __FILE__, 176)); | - | ||||||||||||
129 | ((value) ? static_cast<void>(0) : qt_assert("value", __FILE__, 177)); | - | ||||||||||||
130 | *key = m_keys[idx]; | - | ||||||||||||
131 | *value = m_values[idx]; | - | ||||||||||||
132 | } executed 400 times by 1 test: end of block Executed by:
| 400 | ||||||||||||
Switch to Source code | Preprocessed file |