Skip to content

Commit

Permalink
Merge pull request godotengine#12 from lawnjelly/growable_message_queue3
Browse files Browse the repository at this point in the history
Make MessageQueue growable
  • Loading branch information
lawnjelly authored Mar 31, 2023
2 parents 8b924aa + 5f1e7e6 commit f20623b
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 106 deletions.
6 changes: 4 additions & 2 deletions core/local_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ class LocalVector {
}
}
_FORCE_INLINE_ bool empty() const { return count == 0; }
_FORCE_INLINE_ void reserve(U p_size) {
_FORCE_INLINE_ U get_capacity() const { return capacity; }

_FORCE_INLINE_ void reserve(U p_size, bool p_allow_shrink = false) {
p_size = nearest_power_of_2_templated(p_size);
if (p_size > capacity) {
if (!p_allow_shrink ? p_size > capacity : ((p_size >= count) && (p_size != capacity))) {
capacity = p_size;
data = (T *)memrealloc(data, capacity * sizeof(T));
CRASH_COND_MSG(!data, "Out of memory");
Expand Down
Loading

0 comments on commit f20623b

Please sign in to comment.