Merge pull request #3404 from sfc-gh-tclinkenbeard/add-vectorref-clear

Added VectorRef::clear
This commit is contained in:
Jingyu Zhou 2021-06-07 13:44:08 -07:00 committed by GitHub
commit 801258e916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -792,6 +792,7 @@ struct VectorRefPreserializer {
void invalidate() {}
void add(const T& item) {}
void remove(const T& item) {}
void reset() {}
};
template <class T>
@ -823,6 +824,7 @@ struct VectorRefPreserializer<T, VecSerStrategy::String> {
_cached_size -= _string_traits.getSize(item);
}
}
void reset() { _cached_size = 0; }
};
template <class T, VecSerStrategy SerStrategy = VecSerStrategy::FlatBuffers>
@ -1041,6 +1043,11 @@ public:
m_size = size;
}
void clear() {
VPS::reset();
m_size = 0;
}
void reserve(Arena& p, int size) {
if (size > m_capacity)
reallocate(p, size);