mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +00:00
Merge pull request #2832 from rciorba/hash_modulo_speedup
replace modulo with if to check for wraparound in hashmap
This commit is contained in:
commit
0c6a11a9f2
1 changed files with 8 additions and 2 deletions
|
@ -146,7 +146,10 @@ hashindex_lookup(HashIndex *index, const void *key, int *start_idx)
|
|||
}
|
||||
return idx;
|
||||
}
|
||||
idx = (idx + 1) % index->num_buckets;
|
||||
idx++;
|
||||
if (idx >= index->num_buckets) {
|
||||
idx -= index->num_buckets;
|
||||
}
|
||||
if(idx == start) {
|
||||
break;
|
||||
}
|
||||
|
@ -547,7 +550,10 @@ hashindex_set(HashIndex *index, const void *key, const void *value)
|
|||
}
|
||||
idx = start_idx;
|
||||
while(!BUCKET_IS_EMPTY(index, idx) && !BUCKET_IS_DELETED(index, idx)) {
|
||||
idx = (idx + 1) % index->num_buckets;
|
||||
idx++;
|
||||
if (idx >= index->num_buckets){
|
||||
idx -= index->num_buckets;
|
||||
}
|
||||
}
|
||||
if(BUCKET_IS_EMPTY(index, idx)){
|
||||
index->num_empty--;
|
||||
|
|
Loading…
Reference in a new issue