f17-improvement-consistency-performance #25

Merged
Mineplay merged 33 commits from f17-improvement-consistency-performance into main 2025-07-10 16:57:05 -05:00
Showing only changes of commit b43b5c550d - Show all commits

View file

@ -199,15 +199,8 @@ FledastyError fledasty_linked_list_insert_before_value(FledastyLinkedList *curre
FledastyLinkedListNode *previous_node = NULL; FledastyLinkedListNode *previous_node = NULL;
FledastyLinkedListNode *current_node = current_linked_list->start; FledastyLinkedListNode *current_node = current_linked_list->start;
while (current_node != NULL && !hallocy_compare_memory(current_node->value, before_value, current_linked_list->element_byte_size)) { while (current_node != NULL) {
previous_node = current_node; if (hallocy_compare_memory(current_node->value, before_value, current_linked_list->element_byte_size)) {
current_node = current_node->next;
}
if (current_node == NULL) {
return FLEDASTY_ERROR_VALUE_NOT_FOUND;
}
FledastyLinkedListNode *new_node = (FledastyLinkedListNode*)hallocy_malloc(sizeof(FledastyLinkedListNode)); FledastyLinkedListNode *new_node = (FledastyLinkedListNode*)hallocy_malloc(sizeof(FledastyLinkedListNode));
if (new_node == NULL) { if (new_node == NULL) {
return FLEDASTY_ERROR_FAILED_ALLOCATION; return FLEDASTY_ERROR_FAILED_ALLOCATION;
@ -230,6 +223,13 @@ FledastyError fledasty_linked_list_insert_before_value(FledastyLinkedList *curre
current_linked_list->size += 1; current_linked_list->size += 1;
return FLEDASTY_ERROR_NONE; return FLEDASTY_ERROR_NONE;
}
previous_node = current_node;
current_node = current_node->next;
}
return FLEDASTY_ERROR_VALUE_NOT_FOUND;
} }
FledastyError fledasty_linked_list_insert_after_value(FledastyLinkedList *current_linked_list, void *after_value, void *value) { FledastyError fledasty_linked_list_insert_after_value(FledastyLinkedList *current_linked_list, void *after_value, void *value) {
@ -238,14 +238,8 @@ FledastyError fledasty_linked_list_insert_after_value(FledastyLinkedList *curren
} }
FledastyLinkedListNode *current_node = current_linked_list->start; FledastyLinkedListNode *current_node = current_linked_list->start;
while (current_node != NULL && !hallocy_compare_memory(current_node->value, after_value, current_linked_list->element_byte_size)) { while (current_node != NULL) {
current_node = current_node->next; if (hallocy_compare_memory(current_node->value, after_value, current_linked_list->element_byte_size)) {
}
if (current_node == NULL) {
return FLEDASTY_ERROR_VALUE_NOT_FOUND;
}
FledastyLinkedListNode *new_node = (FledastyLinkedListNode*)hallocy_malloc(sizeof(FledastyLinkedListNode)); FledastyLinkedListNode *new_node = (FledastyLinkedListNode*)hallocy_malloc(sizeof(FledastyLinkedListNode));
if (new_node == NULL) { if (new_node == NULL) {
return FLEDASTY_ERROR_FAILED_ALLOCATION; return FLEDASTY_ERROR_FAILED_ALLOCATION;
@ -270,6 +264,12 @@ FledastyError fledasty_linked_list_insert_after_value(FledastyLinkedList *curren
current_linked_list->size += 1; current_linked_list->size += 1;
return FLEDASTY_ERROR_NONE; return FLEDASTY_ERROR_NONE;
}
current_node = current_node->next;
}
return FLEDASTY_ERROR_VALUE_NOT_FOUND;
} }
FledastyError fledasty_linked_list_remove_at_index(FledastyLinkedList *current_linked_list, const size_t index) { FledastyError fledasty_linked_list_remove_at_index(FledastyLinkedList *current_linked_list, const size_t index) {
@ -317,15 +317,8 @@ FledastyError fledasty_linked_list_remove_value(FledastyLinkedList *current_link
FledastyLinkedListNode *previous_node = NULL; FledastyLinkedListNode *previous_node = NULL;
FledastyLinkedListNode *current_node = current_linked_list->start; FledastyLinkedListNode *current_node = current_linked_list->start;
while (current_node != NULL && !hallocy_compare_memory(current_node->value, value, current_linked_list->element_byte_size)) { while (current_node != NULL) {
previous_node = current_node; if (hallocy_compare_memory(current_node->value, value, current_linked_list->element_byte_size)) {
current_node = current_node->next;
}
if (current_node == NULL) {
return FLEDASTY_ERROR_VALUE_NOT_FOUND;
}
if (current_node == current_linked_list->end) { if (current_node == current_linked_list->end) {
current_linked_list->end = previous_node; current_linked_list->end = previous_node;
} }
@ -346,6 +339,13 @@ FledastyError fledasty_linked_list_remove_value(FledastyLinkedList *current_link
current_linked_list->size -= 1; current_linked_list->size -= 1;
return FLEDASTY_ERROR_NONE; return FLEDASTY_ERROR_NONE;
}
previous_node = current_node;
current_node = current_node->next;
}
return FLEDASTY_ERROR_VALUE_NOT_FOUND;
} }
FledastyError fledasty_linked_list_clear(FledastyLinkedList *current_linked_list) { FledastyError fledasty_linked_list_clear(FledastyLinkedList *current_linked_list) {
@ -368,10 +368,10 @@ FledastyError fledasty_linked_list_clear(FledastyLinkedList *current_linked_list
} }
} }
current_linked_list->size = 0;
current_linked_list->start = NULL; current_linked_list->start = NULL;
current_linked_list->end = NULL; current_linked_list->end = NULL;
current_linked_list->size = 0;
return FLEDASTY_ERROR_NONE; return FLEDASTY_ERROR_NONE;
} }