perf(queue): improved peek function by inlining it
This commit is contained in:
parent
f7ac0e5192
commit
06cc299160
2 changed files with 1 additions and 10 deletions
|
|
@ -40,11 +40,11 @@ FledastyError fledasty_queue_initialize(FledastyQueue *new_queue, void *values,
|
||||||
FledastyError fledasty_queue_destroy(FledastyQueue *current_queue);
|
FledastyError fledasty_queue_destroy(FledastyQueue *current_queue);
|
||||||
|
|
||||||
FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value);
|
FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value);
|
||||||
void *fledasty_queue_peek(const FledastyQueue *current_queue);
|
|
||||||
void *fledasty_queue_pop(FledastyQueue *current_queue);
|
void *fledasty_queue_pop(FledastyQueue *current_queue);
|
||||||
|
|
||||||
FledastyError fledasty_queue_clear(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; }
|
static inline bool fledasty_queue_is_empty(const FledastyQueue *current_queue) { return current_queue == NULL || current_queue->size == 0; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ FledastyError fledasty_queue_initialize(FledastyQueue *new_queue, void *values,
|
||||||
}
|
}
|
||||||
|
|
||||||
new_queue->tail = new_queue->size;
|
new_queue->tail = new_queue->size;
|
||||||
|
|
||||||
return FLEDASTY_ERROR_NONE;
|
return FLEDASTY_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,14 +101,6 @@ FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value) {
|
||||||
return FLEDASTY_ERROR_NONE;
|
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) {
|
void *fledasty_queue_pop(FledastyQueue *current_queue) {
|
||||||
if (current_queue == NULL || current_queue->size == 0) {
|
if (current_queue == NULL || current_queue->size == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue