[common] vector: inline common operations

This commit is contained in:
Quantum 2021-08-27 00:17:40 -04:00 committed by Geoffrey McRae
parent ceff9dca9b
commit ba527761ef
2 changed files with 10 additions and 13 deletions

View File

@ -34,10 +34,18 @@ Vector;
Vector * vector_create(size_t itemSize, size_t capacity);
void vector_free(Vector * vector);
inline static size_t vector_size(Vector * vector)
{
return vector->size;
}
inline static void * vector_data(Vector * vector)
{
return vector->data;
}
void * vector_push(Vector * vector, void * item);
void vector_pop(Vector * vector);
size_t vector_size(Vector * vector);
void * vector_data(Vector * vector);
void vector_at(Vector * vector, size_t index, void * data);
void * vector_ptrTo(Vector * vector, size_t index);
void vector_clear(Vector * vector);
@ -59,7 +67,6 @@ void vector_clear(Vector * vector);
index < (vector)->size ? vector_at((vector), index, &(name)), true : false; \
++index)
#define vector_forEachRefIdx(index, name, vector) \
for (size_t index = 0; \
index < (vector)->size ? (name) = vector_ptrTo((vector), index), true : false; \

View File

@ -82,16 +82,6 @@ void vector_pop(Vector * vector)
--vector->size;
}
size_t vector_size(Vector * vector)
{
return vector->size;
}
void * vector_data(Vector * vector)
{
return vector->data;
}
void vector_at(Vector * vector, size_t index, void * data)
{
DEBUG_ASSERT(index < vector->size && "Out of bounds access");