Skip to content
Myr

jv_array_indexes: remove a bunch of unnecessary copies/gets

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Emanuele Torre · committed by Emanuele Torre · parent 22a03e9 · Browse files · 1 file+3 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−4 removed

  • other:+3 added−4 removed

1 file+3 added−4 removed

modified:src/jv.c+3 added-4 removed
1023 unmodified lines
10241025jv jv_array_indexes(jv a, jv b) {1026 jv res = jv_array();1027 int idx = -1;1028 jv_array_foreach(a, ai, aelem) {1029 jv_free(aelem);1028 int alen = jv_array_length(jv_copy(a));1029 for (int ai = 0; ai < alen; ++ai) {1030 jv_array_foreach(b, bi, belem) {1031 if (!jv_equal(jv_array_get(jv_copy(a), ai + bi), jv_copy(belem)))1031 if (!jv_equal(jv_array_get(jv_copy(a), ai + bi), belem))1032 idx = -1;1033 else if (bi == 0 && idx == -1)1034 idx = ai;1035 jv_free(belem);1035 }1036 if (idx > -1)1037 res = jv_array_append(res, jv_number(idx));1038 idx = -1;
939 unmodified lines