Skip to content

Commit

Permalink
jv_aux.c: replace jv_array_foreach with regular loop in jv_dels()
Browse files Browse the repository at this point in the history
The code was only conditionally using the value
  • Loading branch information
emanuele6 committed Mar 28, 2024
1 parent ea78b5a commit ce2638a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/jv_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static jv jv_dels(jv t, jv keys) {
int neg_idx = 0;
int nonneg_idx = 0;
int len = jv_array_length(jv_copy(t));
jv_array_foreach(t, i, elem) {
for (int i = 0; i < len; ++i) {
int del = 0;
while (neg_idx < jv_array_length(jv_copy(neg_keys))) {
int delidx = len + (int)jv_number_get_value_and_consume(jv_array_get(jv_copy(neg_keys), neg_idx));
Expand Down Expand Up @@ -343,9 +343,7 @@ static jv jv_dels(jv t, jv keys) {
}
}
if (!del)
new_array = jv_array_append(new_array, elem);
else
jv_free(elem);
new_array = jv_array_append(new_array, jv_array_get(jv_copy(t), i));
}
arr_out:
jv_free(neg_keys);
Expand Down

0 comments on commit ce2638a

Please sign in to comment.