Skip to content

Commit 4f1923e

Browse files
authored
Merge pull request libgit2#5390 from pks-t/pks/sha1-lookup
sha1_lookup: inline its only function into "pack.c"
2 parents 8aa04a3 + f0f1cd1 commit 4f1923e

File tree

4 files changed

+21
-56
lines changed

4 files changed

+21
-56
lines changed

src/odb_pack.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "hash.h"
1616
#include "odb.h"
1717
#include "delta.h"
18-
#include "sha1_lookup.h"
1918
#include "mwindow.h"
2019
#include "pack.h"
2120

src/pack.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "mwindow.h"
1313
#include "odb.h"
1414
#include "oid.h"
15-
#include "sha1_lookup.h"
1615

1716
/* Option to bypass checking existence of '.keep' files */
1817
bool git_disable_pack_keep_file_checks = false;
@@ -1239,6 +1238,27 @@ int git_pack_foreach_entry(
12391238
return error;
12401239
}
12411240

1241+
static int sha1_position(const void *table, size_t stride, unsigned lo,
1242+
unsigned hi, const unsigned char *key)
1243+
{
1244+
const unsigned char *base = table;
1245+
1246+
while (lo < hi) {
1247+
unsigned mi = (lo + hi) / 2;
1248+
int cmp = git_oid__hashcmp(base + mi * stride, key);
1249+
1250+
if (!cmp)
1251+
return mi;
1252+
1253+
if (cmp > 0)
1254+
hi = mi;
1255+
else
1256+
lo = mi+1;
1257+
}
1258+
1259+
return -((int)lo)-1;
1260+
}
1261+
12421262
static int pack_entry_find_offset(
12431263
off64_t *offset_out,
12441264
git_oid *found_oid,

src/sha1_lookup.c

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/sha1_lookup.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)