Skip to content

Commit 6f3992b

Browse files
committed
priority queue should truncate when capacity is equal to the threshold
1 parent 6006e41 commit 6f3992b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ds/ds_priority_queue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static inline void reallocate_to_capacity(ds_priority_queue_t *queue, uint32_t c
5353

5454
static inline void increase_capacity(ds_priority_queue_t *queue)
5555
{
56-
reallocate_to_capacity(queue, queue->capacity << 1);
56+
reallocate_to_capacity(queue, queue->capacity * 2);
5757
}
5858

5959
void ds_priority_queue_allocate(ds_priority_queue_t *queue, uint32_t capacity)
@@ -118,7 +118,7 @@ void ds_priority_queue_push(ds_priority_queue_t *queue, zval *value, zend_long p
118118

119119
static inline void ds_priority_queue_compact(ds_priority_queue_t *queue)
120120
{
121-
if (queue->size < (queue->capacity / 4) && (queue->capacity / 2) > DS_PRIORITY_QUEUE_MIN_CAPACITY) {
121+
if (queue->size <= (queue->capacity / 4) && (queue->capacity / 2) >= DS_PRIORITY_QUEUE_MIN_CAPACITY) {
122122
reallocate_to_capacity(queue, queue->capacity / 2);
123123
}
124124
}

0 commit comments

Comments
 (0)