perf(stack): improved peek function by inlining it
This commit is contained in:
parent
06cc299160
commit
349268068b
2 changed files with 1 additions and 9 deletions
|
|
@ -39,12 +39,12 @@ FledastyError fledasty_stack_initialize(FledastyStack *new_stack, void *values,
|
|||
FledastyError fledasty_stack_destroy(FledastyStack *current_stack);
|
||||
|
||||
FledastyError fledasty_stack_push(FledastyStack *current_stack, void *value);
|
||||
void *fledasty_stack_peek(const FledastyStack *current_stack);
|
||||
void *fledasty_stack_pop(FledastyStack *current_stack);
|
||||
|
||||
FledastyError fledasty_stack_clear(FledastyStack *current_stack);
|
||||
FledastyError fledasty_stack_shrink_to_fit(FledastyStack *current_stack);
|
||||
|
||||
static inline void *fledasty_stack_peek(const FledastyStack *current_stack) { (current_stack == NULL) ? NULL : current_stack->buffer + ((current_stack->size - 1) * current_stack->element_byte_size); }
|
||||
static inline bool fledasty_stack_is_empty(const FledastyStack *current_stack) { return current_stack == NULL || current_stack->size == 0; }
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -90,14 +90,6 @@ FledastyError fledasty_stack_push(FledastyStack *current_stack, void *value) {
|
|||
return FLEDASTY_ERROR_NONE;
|
||||
}
|
||||
|
||||
void *fledasty_stack_peek(const FledastyStack *current_stack) {
|
||||
if (current_stack == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return current_stack->buffer + ((current_stack->size - 1) * current_stack->element_byte_size);
|
||||
}
|
||||
|
||||
void *fledasty_stack_pop(FledastyStack *current_stack) {
|
||||
if (current_stack == NULL) {
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue