Skip to content

Commit bb8ac99

Browse files
authored
Better match for add_unused_obj_index (#734)
1 parent a927b1d commit bb8ac99

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/update_objects.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,18 @@ s32 add_unused_obj_index(s32* listIdx, s32* nextFree, s32 size) {
161161
}
162162
count = 0;
163163
id = &listIdx[*nextFree];
164-
/**
165-
* @todo This HAS to be a for-loop of some variety, but I can't make a for-loop to match.
166-
* If you replace this with ```for(var_v1 = 0; var_v1 < size; var_v1++)```
167-
* The diff gets massive.
168-
*/
169-
if (size > 0) {
170-
loop_3:
164+
165+
for (count = 0; count < size; count++) {
171166
if (*id == NULL_OBJECT_ID) {
172167
objectIndex = find_unused_obj_index(id);
173168
*nextFree += 1;
169+
break;
174170
} else {
175171
*nextFree += 1;
176172
if (*nextFree >= size) {
177173
*nextFree = 0;
178174
}
179-
count += 1;
180175
id = &listIdx[*nextFree];
181-
if (count != size) { // check if don't check all element of the list
182-
goto loop_3;
183-
}
184176
}
185177
}
186178
if (count == size) {

0 commit comments

Comments
 (0)