diff options
author | Patrick Steinhardt <ps@pks.im> | 2020-02-19 12:14:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 12:14:32 +0100 |
commit | 4f1923e85e0814518b988aa174f2876f6cd1d36a (patch) | |
tree | 91e6151541d52485db22871c8e37b66627156338 /src | |
parent | 8aa04a37d180240edb68db4267a0895ce38e9fc3 (diff) | |
parent | f0f1cd1dae5e7ebf2c631cc297b2b3652eaca170 (diff) | |
download | libgit2-4f1923e85e0814518b988aa174f2876f6cd1d36a.tar.gz |
Merge pull request #5390 from pks-t/pks/sha1-lookup
sha1_lookup: inline its only function into "pack.c"
Diffstat (limited to 'src')
-rw-r--r-- | src/odb_pack.c | 1 | ||||
-rw-r--r-- | src/pack.c | 22 | ||||
-rw-r--r-- | src/sha1_lookup.c | 35 | ||||
-rw-r--r-- | src/sha1_lookup.h | 19 |
4 files changed, 21 insertions, 56 deletions
diff --git a/src/odb_pack.c b/src/odb_pack.c index c93d07c46..86c858df1 100644 --- a/src/odb_pack.c +++ b/src/odb_pack.c @@ -15,7 +15,6 @@ #include "hash.h" #include "odb.h" #include "delta.h" -#include "sha1_lookup.h" #include "mwindow.h" #include "pack.h" diff --git a/src/pack.c b/src/pack.c index 7c6fc2cdb..fcf64f57d 100644 --- a/src/pack.c +++ b/src/pack.c @@ -12,7 +12,6 @@ #include "mwindow.h" #include "odb.h" #include "oid.h" -#include "sha1_lookup.h" /* Option to bypass checking existence of '.keep' files */ bool git_disable_pack_keep_file_checks = false; @@ -1239,6 +1238,27 @@ int git_pack_foreach_entry( return error; } +static int sha1_position(const void *table, size_t stride, unsigned lo, + unsigned hi, const unsigned char *key) +{ + const unsigned char *base = table; + + while (lo < hi) { + unsigned mi = (lo + hi) / 2; + int cmp = git_oid__hashcmp(base + mi * stride, key); + + if (!cmp) + return mi; + + if (cmp > 0) + hi = mi; + else + lo = mi+1; + } + + return -((int)lo)-1; +} + static int pack_entry_find_offset( off64_t *offset_out, git_oid *found_oid, diff --git a/src/sha1_lookup.c b/src/sha1_lookup.c deleted file mode 100644 index 14fcb40e5..000000000 --- a/src/sha1_lookup.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) the libgit2 contributors. All rights reserved. - * - * This file is part of libgit2, distributed under the GNU GPL v2 with - * a Linking Exception. For full terms see the included COPYING file. - */ - -#include "sha1_lookup.h" - -#include <stdio.h> - -#include "oid.h" - -int sha1_position(const void *table, - size_t stride, - unsigned lo, unsigned hi, - const unsigned char *key) -{ - const unsigned char *base = table; - - while (lo < hi) { - unsigned mi = (lo + hi) / 2; - int cmp = git_oid__hashcmp(base + mi * stride, key); - - if (!cmp) - return mi; - - if (cmp > 0) - hi = mi; - else - lo = mi+1; - } - - return -((int)lo)-1; -} diff --git a/src/sha1_lookup.h b/src/sha1_lookup.h deleted file mode 100644 index 841ea5b22..000000000 --- a/src/sha1_lookup.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) the libgit2 contributors. All rights reserved. - * - * This file is part of libgit2, distributed under the GNU GPL v2 with - * a Linking Exception. For full terms see the included COPYING file. - */ -#ifndef INCLUDE_sha1_lookup_h__ -#define INCLUDE_sha1_lookup_h__ - -#include "common.h" - -#include <stdlib.h> - -int sha1_position(const void *table, - size_t stride, - unsigned lo, unsigned hi, - const unsigned char *key); - -#endif |