Skip to content

Commit

Permalink
styleStyle fixes from suggestions.
Browse files Browse the repository at this point in the history
Co-authored-by: itchyny <itchyny@cybozu.co.jp>
  • Loading branch information
eloycoto and itchyny authored Feb 5, 2024
1 parent 949b647 commit 50fc13a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ static jv f_bsearch(jq_state *jq, jv input, jv target) {
return jv_number(-1);
} else if (len == 1) {
int result = jv_cmp(target, jv_array_get(input, 0));
if (result == 0 ) {
if (result == 0) {
return jv_number(0);
} else if (result > 0) {
return jv_number(-2);
Expand All @@ -804,26 +804,26 @@ static jv f_bsearch(jq_state *jq, jv input, jv target) {
int start = 0;
int end = len - 1;
jv answer = jv_null();
while (start <end) {
while (start < end) {
int mid = (start + end) / 2;
int result = jv_cmp(jv_copy(target), jv_array_get(jv_copy(input), mid));
if (result == 0) {
answer = jv_number(mid);
break;
} else if (start == end ) {
} else if (start == end) {
answer = jv_number(-1);
break;
} else if (result < 0 ) {
end = mid -1;
} else if (result < 0) {
end = mid - 1;
} else {
start = mid +1;
start = mid + 1;
}
}
if (jv_get_kind(answer) == JV_KIND_NULL) {
int result = jv_cmp(target, jv_array_get(jv_copy(input), start));
if (result < 0) {
answer = jv_number(-1 - start);
}else {
} else {
answer = jv_number(-2 - start);
}
} else {
Expand Down

0 comments on commit 50fc13a

Please sign in to comment.