Skip to content

Commit

Permalink
Merge pull request #75527 from lawnjelly/growable_message_queue3
Browse files Browse the repository at this point in the history
[3.x] Make MessageQueue growable
  • Loading branch information
akien-mga authored Apr 11, 2023
2 parents b14a759 + 5f1e7e6 commit 632a544
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 632a544

Please sign in to comment.