mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Changed C++'s SharedVector::clear() to not preserve capacity when shared
This commit is contained in:
parent
d65af654d7
commit
a752c798b8
2 changed files with 8 additions and 6 deletions
|
@ -130,10 +130,9 @@ struct SharedVector
|
|||
/// Clears the vector and removes all elements. The capacity remains unaffected.
|
||||
void clear()
|
||||
{
|
||||
// Detach first to retain capacity, so that the begin() call doesn't detach
|
||||
// (which it would to inner->size instead of capacity)
|
||||
detach(inner->capacity);
|
||||
{
|
||||
if (inner->refcount != 1) {
|
||||
*this = SharedVector();
|
||||
} else {
|
||||
auto b = begin(), e = end();
|
||||
inner->size = 0;
|
||||
for (auto it = b; it < e; ++it) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue