Fix individual_element_index when some type has 0 elements.
When some type has 0 elements, saved_individual_element_index was set to -1 on second type bump, since individual_element_index was not restored after the first. To me it looks easier just to increment saved_individual_element_index separately than think when to save it. MFC after: 2 weeks
This commit is contained in:
parent
4bfbbd74a8
commit
daf9d8f42e
@ -444,6 +444,7 @@ ses_iter_next(struct ses_iterator *iter)
|
||||
iter->type_element_index = ITERATOR_INDEX_END;
|
||||
iter->global_element_index = ITERATOR_INDEX_END;
|
||||
iter->individual_element_index = ITERATOR_INDEX_END;
|
||||
iter->saved_individual_element_index = ITERATOR_INDEX_END;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -468,17 +469,12 @@ ses_iter_next(struct ses_iterator *iter)
|
||||
*/
|
||||
iter->type_index++;
|
||||
iter->type_element_index = 0;
|
||||
iter->saved_individual_element_index
|
||||
= iter->individual_element_index;
|
||||
iter->individual_element_index = ITERATOR_INDEX_INVALID;
|
||||
}
|
||||
|
||||
if (iter->type_element_index > 0) {
|
||||
if (iter->type_element_index == 1) {
|
||||
iter->individual_element_index
|
||||
= iter->saved_individual_element_index;
|
||||
}
|
||||
iter->individual_element_index++;
|
||||
iter->individual_element_index =
|
||||
++iter->saved_individual_element_index;
|
||||
}
|
||||
|
||||
return (&iter->cache->elm_map[iter->global_element_index]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user