diff options
author | Vicent Marti <tanoku@gmail.com> | 2015-10-14 19:31:54 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2015-10-14 20:53:01 +0200 |
commit | a0a1b19ab043f3579aabfb7602b4c4ac4dd69e72 (patch) | |
tree | b259c688fa865a62ef4236306dbd7342d98424a1 /src | |
parent | 43820f204ea32503b4083e3b6b83f30a0a0031c9 (diff) | |
download | libgit2-vmg/odb-lookups.tar.gz |
odb: Prioritize alternate backendsvmg/odb-lookups
For most real use cases, repositories with alternates use them as main
object storage. Checking the alternate for objects before the main
repository should result in measurable speedups.
Because of this, we're changing the sorting algorithm to prioritize
alternates *in cases where two backends have the same priority*. This
means that the pack backend for the alternate will be checked before the
pack backend for the main repository *but* both of them will be checked
before any loose backends.
Diffstat (limited to 'src')
-rw-r--r-- | src/odb.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -374,10 +374,14 @@ static int backend_sort_cmp(const void *a, const void *b) const backend_internal *backend_a = (const backend_internal *)(a); const backend_internal *backend_b = (const backend_internal *)(b); - if (backend_a->is_alternate == backend_b->is_alternate) - return (backend_b->priority - backend_a->priority); - - return backend_a->is_alternate ? 1 : -1; + if (backend_b->priority == backend_a->priority) { + if (backend_a->is_alternate) + return -1; + if (backend_b->is_alternate) + return 1; + return 0; + } + return (backend_b->priority - backend_a->priority); } int git_odb_new(git_odb **out) |