mirror of
git://erdgeist.org/opentracker
synced 2025-01-27 07:06:45 +00:00
binary search speedup was buggy.
This commit is contained in:
parent
0c8a17cbef
commit
c3a58d248b
@ -27,10 +27,10 @@ static int vector_compare_peer(const void *peer1, const void *peer2 ) {
|
||||
*/
|
||||
void *binary_search( const void * const key, const void * base, const size_t member_count, const size_t member_size,
|
||||
size_t compare_size, int *exactmatch ) {
|
||||
size_t interval = member_count * member_size;
|
||||
size_t interval = member_count;
|
||||
|
||||
while( interval ) {
|
||||
uint8_t *lookat = ((uint8_t*)base) + interval / 2;
|
||||
uint8_t *lookat = ((uint8_t*)base) + member_size * ( interval / 2 );
|
||||
int cmp = memcmp( lookat, key, compare_size );
|
||||
if(cmp == 0 ) {
|
||||
base = lookat;
|
||||
@ -38,7 +38,7 @@ void *binary_search( const void * const key, const void * base, const size_t mem
|
||||
}
|
||||
if(cmp < 0) {
|
||||
base = lookat + member_size;
|
||||
interval -= member_size;
|
||||
interval --;
|
||||
}
|
||||
interval /= 2;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user