diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-08-22 09:33:17 +0300 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-08-22 09:33:17 +0300 |
| commit | c6fdadd916a7568c1d71b750e054ca9aa2fd5dfc (patch) | |
| tree | bbd5690b38a5e0df66dd070a9e9f42b0d1b2b673 /src/qml/jsruntime/qv4estable.cpp | |
| parent | a7c766a9863605eb81e8f0cdb4d2b93e087b5bde (diff) | |
| parent | e436dad999060b92965291b45c0e95a3b93f5866 (diff) | |
Merge tag 'v6.2.13-lts' into tqtc/lts-6.2-opensourcev6.2.13-lts-lgpl6.2
Qt 6.2.13-lts release
Conflicts solved:
dependencies.yaml
Change-Id: I3cbe1ce4293179888e236dd1a3a299cd2c66c950
Diffstat (limited to 'src/qml/jsruntime/qv4estable.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4estable.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4estable.cpp b/src/qml/jsruntime/qv4estable.cpp index 99f6bf6aa0..2e504a70cb 100644 --- a/src/qml/jsruntime/qv4estable.cpp +++ b/src/qml/jsruntime/qv4estable.cpp @@ -147,21 +147,18 @@ ReturnedValue ESTable::get(const Value &key, bool *hasValue) const // Removes the given \a key from the table bool ESTable::remove(const Value &key) { - bool found = false; - uint idx = 0; - for (; idx < m_size; ++idx) { - if (m_keys[idx].sameValueZero(key)) { - found = true; - break; + for (uint index = 0; index < m_size; ++index) { + if (m_keys[index].sameValueZero(key)) { + // Remove the element at |index| by moving all elements to the right + // of |index| one place to the left. + size_t count = (m_size - (index + 1)) * sizeof(Value); + memmove(m_keys + index, m_keys + index + 1, count); + memmove(m_values + index, m_values + index + 1, count); + m_size--; + return true; } } - - if (found == true) { - memmove(m_keys + idx, m_keys + idx + 1, (m_size - idx)*sizeof(Value)); - memmove(m_values + idx, m_values + idx + 1, (m_size - idx)*sizeof(Value)); - m_size--; - } - return found; + return false; } // Returns the size of the table. Note that the size may not match the underlying allocation. |
