Skip to content

Commit

Permalink
Rename of vector auto truncate func
Browse files Browse the repository at this point in the history
  • Loading branch information
rtheunissen committed Jul 19, 2017
1 parent a58b4e9 commit 9ccc4ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ds/ds_vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ static inline void ds_vector_ensure_capacity(ds_vector_t *vector, zend_long capa
}
}

static inline void ds_vector_check_compact(ds_vector_t *vector)
static inline void ds_vector_auto_truncate(ds_vector_t *vector)
{
const zend_long c = vector->capacity;
const zend_long n = vector->size;

if (n < c / 4 && c / 2 > DS_VECTOR_MIN_CAPACITY) {
if (n <= c / 4 && c / 2 >= DS_VECTOR_MIN_CAPACITY) {
ds_vector_reallocate(vector, c / 2);
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@ void ds_vector_remove(ds_vector_t *vector, zend_long index, zval *return_value)
memmove(pos, pos + 1, sizeof(zval) * (vector->size - index));
vector->size--;

ds_vector_check_compact(vector);
ds_vector_auto_truncate(vector);
}
}

Expand Down Expand Up @@ -458,7 +458,7 @@ ds_vector_t *ds_vector_merge(ds_vector_t *vector, zval *values)
void ds_vector_pop(ds_vector_t *vector, zval *return_value)
{
SET_AS_RETURN_AND_UNDEF(&vector->buffer[--vector->size]);
ds_vector_check_compact(vector);
ds_vector_auto_truncate(vector);
}

void ds_vector_pop_throw(ds_vector_t *vector, zval *return_value)
Expand All @@ -479,7 +479,7 @@ void ds_vector_shift(ds_vector_t *vector, zval *return_value)

vector->size--;
memmove(first, first + 1, vector->size * sizeof(zval));
ds_vector_check_compact(vector);
ds_vector_auto_truncate(vector);
}

void ds_vector_shift_throw(ds_vector_t *vector, zval *return_value)
Expand Down

0 comments on commit 9ccc4ec

Please sign in to comment.