summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cvec.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-07-28 00:20:43 +0200
committerTyge Løvset <[email protected]>2022-07-28 00:21:59 +0200
commit18392a1f49bb742fce3e28bb8196b2a64ea07219 (patch)
tree1126f78172a5ac04257ac9de6b979ecd671fbfad /include/stc/cvec.h
parent95e05bac8e77c17e9ad867c9508d44d7e9790a30 (diff)
downloadSTC-modified-18392a1f49bb742fce3e28bb8196b2a64ea07219.tar.gz
STC-modified-18392a1f49bb742fce3e28bb8196b2a64ea07219.zip
Added back coption.h and coption_api.md docs.
Diffstat (limited to 'include/stc/cvec.h')
-rw-r--r--include/stc/cvec.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 19303125..81678293 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -409,17 +409,16 @@ _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) {
}
STC_DEF _cx_iter
-_cx_memb(_binary_search_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw, _cx_iter* lower_bound) {
+_cx_memb(_binary_search_in)(_cx_iter i1, _cx_iter i2, const _cx_raw raw, _cx_iter* lower_bound) {
_cx_iter mid, last = i2;
while (i1.ref != i2.ref) {
- mid.ref = i1.ref + ((i2.ref - i1.ref) >> 1);
- int c; const _cx_raw m = i_keyto(mid.ref);
- if (!(c = i_cmp((&raw), (&m))))
- return *lower_bound = mid;
- else if (c < 0)
- i2.ref = mid.ref;
- else
- i1.ref = mid.ref + 1;
+ mid.ref = i1.ref + (i2.ref - i1.ref)/2;
+ const _cx_raw m = i_keyto(mid.ref);
+ const int c = i_cmp((&raw), (&m));
+
+ if (!c) return *lower_bound = mid;
+ else if (c < 0) i2.ref = mid.ref;
+ else i1.ref = mid.ref + 1;
}
*lower_bound = i1;
return last;