mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-10 14:15:43 +00:00
hashindex: simplify size_idx function
Thanks to @jdchristensen for the code.
This commit is contained in:
parent
d57fafadad
commit
f1d68fe4b3
1 changed files with 4 additions and 10 deletions
|
@ -246,16 +246,10 @@ int get_min_empty(int num_buckets){
|
||||||
}
|
}
|
||||||
|
|
||||||
int size_idx(int size){
|
int size_idx(int size){
|
||||||
/* find the hash_sizes index with entry >= size */
|
/* find the smallest hash_sizes index with entry >= size */
|
||||||
int elems = NELEMS(hash_sizes);
|
int i = NELEMS(hash_sizes) - 1;
|
||||||
int entry, i=0;
|
while(i >= 0 && hash_sizes[i] >= size) i--;
|
||||||
do{
|
return i + 1;
|
||||||
entry = hash_sizes[i++];
|
|
||||||
}while((entry < size) && (i < elems));
|
|
||||||
if (i >= elems)
|
|
||||||
return elems - 1;
|
|
||||||
i--;
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int fit_size(int current){
|
int fit_size(int current){
|
||||||
|
|
Loading…
Add table
Reference in a new issue