summaryrefslogtreecommitdiff
path: root/update-cache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 16:26:55 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 16:26:55 (GMT)
commiteb38c22f535c7c973f27b62845c5136c4be0ae49 (patch)
treedd229923a70e17998038996d66d4562df16f6d28 /update-cache.c
parent59c1e249808c6ba38194733fa00efddb9e0eb488 (diff)
downloadgit-eb38c22f535c7c973f27b62845c5136c4be0ae49.zip
git-eb38c22f535c7c973f27b62845c5136c4be0ae49.tar.gz
git-eb38c22f535c7c973f27b62845c5136c4be0ae49.tar.bz2
Make "cache_name_pos()" available to others.
It finds the cache entry position for a given name, and is generally useful. Sure, everybody can just scan the active cache array, but since it's sorted, you actually want to search it with a binary search, so let's not duplicate that logic all over the place.
Diffstat (limited to 'update-cache.c')
-rw-r--r--update-cache.c36
1 files changed, 0 insertions, 36 deletions
diff --git a/update-cache.c b/update-cache.c
index 413e09d..7a076be 100644
--- a/update-cache.c
+++ b/update-cache.c
@@ -5,42 +5,6 @@
*/
#include "cache.h"
-static int cache_name_compare(const char *name1, int len1, const char *name2, int len2)
-{
- int len = len1 < len2 ? len1 : len2;
- int cmp;
-
- cmp = memcmp(name1, name2, len);
- if (cmp)
- return cmp;
- if (len1 < len2)
- return -1;
- if (len1 > len2)
- return 1;
- return 0;
-}
-
-static int cache_name_pos(const char *name, int namelen)
-{
- int first, last;
-
- first = 0;
- last = active_nr;
- while (last > first) {
- int next = (last + first) >> 1;
- struct cache_entry *ce = active_cache[next];
- int cmp = cache_name_compare(name, namelen, ce->name, ce->namelen);
- if (!cmp)
- return -next-1;
- if (cmp < 0) {
- last = next;
- continue;
- }
- first = next+1;
- }
- return first;
-}
-
static int remove_file_from_cache(char *path)
{
int pos = cache_name_pos(path, strlen(path));