perf(queue): improved peek function by inlining it

This commit is contained in:
Mineplay 2025-05-15 12:33:07 -05:00
parent f7ac0e5192
commit 06cc299160
2 changed files with 1 additions and 10 deletions

View file

@ -40,11 +40,11 @@ FledastyError fledasty_queue_initialize(FledastyQueue *new_queue, void *values,
FledastyError fledasty_queue_destroy(FledastyQueue *current_queue);
FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value);
void *fledasty_queue_peek(const FledastyQueue *current_queue);
void *fledasty_queue_pop(FledastyQueue *current_queue);
FledastyError fledasty_queue_clear(FledastyQueue *current_queue);
static inline void *fledasty_queue_peek(const FledastyQueue *current_queue) { return (current_queue == NULL) ? NULL : current_queue->buffer + (current_queue->head * current_queue->element_byte_size); }
static inline bool fledasty_queue_is_empty(const FledastyQueue *current_queue) { return current_queue == NULL || current_queue->size == 0; }
#endif

View file

@ -54,7 +54,6 @@ FledastyError fledasty_queue_initialize(FledastyQueue *new_queue, void *values,
}
new_queue->tail = new_queue->size;
return FLEDASTY_ERROR_NONE;
}
@ -102,14 +101,6 @@ FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value) {
return FLEDASTY_ERROR_NONE;
}
void *fledasty_queue_peek(const FledastyQueue *current_queue) {
if (current_queue == NULL) {
return NULL;
}
return current_queue->buffer + (current_queue->head * current_queue->element_byte_size);
}
void *fledasty_queue_pop(FledastyQueue *current_queue) {
if (current_queue == NULL || current_queue->size == 0) {
return NULL;