Sat, 17 Feb 2024 20:51:27 +0100
remove unnecessary flag_removal function
CHANGELOG | file | annotate | diff | comparison | revisions | |
src/array_list.c | file | annotate | diff | comparison | revisions | |
src/cx/iterator.h | file | annotate | diff | comparison | revisions | |
src/hash_map.c | file | annotate | diff | comparison | revisions | |
src/linked_list.c | file | annotate | diff | comparison | revisions |
1.1 --- a/CHANGELOG Sat Feb 17 20:22:13 2024 +0100 1.2 +++ b/CHANGELOG Sat Feb 17 20:51:27 2024 +0100 1.3 @@ -13,6 +13,7 @@ 1.4 * the cx_compare_func symbol is now also declared by compare.h 1.5 * fixes wrong link from UCX 2 documentation to UCX 3 documentation 1.6 * fixes critical bug that produced wrong results when comparing lists of different type but same size 1.7 + * removes flag_removal function from iterator (unfortunately breaks binary compatibility) 1.8 * removes CMake 1.9 * removes GTest dependency 1.10 * removes flags to disable SBO in tests
2.1 --- a/src/array_list.c Sat Feb 17 20:22:13 2024 +0100 2.2 +++ b/src/array_list.c Sat Feb 17 20:51:27 2024 +0100 2.3 @@ -492,15 +492,6 @@ 2.4 } 2.5 } 2.6 2.7 -static bool cx_arl_iter_flag_rm(void *it) { 2.8 - struct cx_iterator_base_s *iter = it; 2.9 - if (iter->mutating) { 2.10 - iter->remove = true; 2.11 - return true; 2.12 - } else { 2.13 - return false; 2.14 - } 2.15 -} 2.16 2.17 static struct cx_iterator_s cx_arl_iterator( 2.18 struct cx_list_s const *list, 2.19 @@ -515,7 +506,6 @@ 2.20 iter.base.valid = cx_arl_iter_valid; 2.21 iter.base.current = cx_arl_iter_current; 2.22 iter.base.next = backwards ? cx_arl_iter_prev : cx_arl_iter_next; 2.23 - iter.base.flag_removal = cx_arl_iter_flag_rm; 2.24 iter.base.remove = false; 2.25 iter.base.mutating = false; 2.26
3.1 --- a/src/cx/iterator.h Sat Feb 17 20:22:13 2024 +0100 3.2 +++ b/src/cx/iterator.h Sat Feb 17 20:51:27 2024 +0100 3.3 @@ -71,14 +71,6 @@ 3.4 void (*next)(void *); 3.5 3.6 /** 3.7 - * Flag current element for removal, if possible. 3.8 - * 3.9 - * When valid returns false, the behavior of this function is undefined. 3.10 - */ 3.11 - __attribute__ ((__nonnull__)) 3.12 - bool (*flag_removal)(void *); 3.13 - 3.14 - /** 3.15 * Indicates whether this iterator may remove elements. 3.16 */ 3.17 bool mutating; 3.18 @@ -243,12 +235,11 @@ 3.19 #define cxIteratorNext(iter) (iter).base.next(&iter) 3.20 3.21 /** 3.22 - * Flags the current element for removal. 3.23 + * Flags the current element for removal, if this iterator is mutating. 3.24 * 3.25 * @param iter the iterator 3.26 - * @return false if this iterator cannot remove the element 3.27 */ 3.28 -#define cxIteratorFlagRemoval(iter) (iter).base.flag_removal(&iter) 3.29 +#define cxIteratorFlagRemoval(iter) (iter).base.remove |= (iter).base.mutating 3.30 3.31 /** 3.32 * Loops over an iterator.
4.1 --- a/src/hash_map.c Sat Feb 17 20:22:13 2024 +0100 4.2 +++ b/src/hash_map.c Sat Feb 17 20:51:27 2024 +0100 4.3 @@ -326,16 +326,6 @@ 4.4 } 4.5 } 4.6 4.7 -static bool cx_hash_map_iter_flag_rm(void *it) { 4.8 - struct cx_iterator_base_s *iter = it; 4.9 - if (iter->mutating) { 4.10 - iter->remove = true; 4.11 - return true; 4.12 - } else { 4.13 - return false; 4.14 - } 4.15 -} 4.16 - 4.17 static CxIterator cx_hash_map_iterator( 4.18 CxMap const *map, 4.19 enum cx_map_iterator_type type 4.20 @@ -360,7 +350,6 @@ 4.21 assert(false); 4.22 } 4.23 4.24 - iter.base.flag_removal = cx_hash_map_iter_flag_rm; 4.25 iter.base.remove = false; 4.26 iter.base.mutating = false; 4.27
5.1 --- a/src/linked_list.c Sat Feb 17 20:22:13 2024 +0100 5.2 +++ b/src/linked_list.c Sat Feb 17 20:51:27 2024 +0100 5.3 @@ -866,16 +866,6 @@ 5.4 return node->payload; 5.5 } 5.6 5.7 -static bool cx_ll_iter_flag_rm(void *it) { 5.8 - struct cx_iterator_base_s *iter = it; 5.9 - if (iter->mutating) { 5.10 - iter->remove = true; 5.11 - return true; 5.12 - } else { 5.13 - return false; 5.14 - } 5.15 -} 5.16 - 5.17 static CxIterator cx_ll_iterator( 5.18 struct cx_list_s const *list, 5.19 size_t index, 5.20 @@ -888,7 +878,6 @@ 5.21 iter.base.valid = cx_ll_iter_valid; 5.22 iter.base.current = cx_ll_iter_current; 5.23 iter.base.next = backwards ? cx_ll_iter_prev : cx_ll_iter_next; 5.24 - iter.base.flag_removal = cx_ll_iter_flag_rm; 5.25 iter.base.mutating = false; 5.26 iter.base.remove = false; 5.27 return iter;