Commit e536fa33 by Edward Thomson Committed by GitHub

Merge pull request #4326 from libgit2/peff/binary-search-do-while

sha1_position: convert do-while to while
parents a9d6b9d5 09930192
...@@ -232,7 +232,7 @@ int sha1_position(const void *table, ...@@ -232,7 +232,7 @@ int sha1_position(const void *table,
{ {
const unsigned char *base = table; const unsigned char *base = table;
do { while (lo < hi) {
unsigned mi = (lo + hi) / 2; unsigned mi = (lo + hi) / 2;
int cmp = git_oid__hashcmp(base + mi * stride, key); int cmp = git_oid__hashcmp(base + mi * stride, key);
...@@ -243,7 +243,7 @@ int sha1_position(const void *table, ...@@ -243,7 +243,7 @@ int sha1_position(const void *table,
hi = mi; hi = mi;
else else
lo = mi+1; lo = mi+1;
} while (lo < hi); }
return -((int)lo)-1; return -((int)lo)-1;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment