scanner: prioritize databases with recent matches

This should improve performance when scanning many files
in a row that all match against the same database, which is
the expectation.
This commit is contained in:
Brian Koropoff 2017-11-08 18:11:05 -08:00
parent b668193923
commit bedf65e72e

View File

@ -868,6 +868,17 @@ static int database_info_list_iterate_found_match(
free(db_playlist_base_str);
free(db_crc);
/* Move database to start since we are likely to match against it
again */
if (db_state->list_index != 0)
{
struct string_list_elem entry = db_state->list->elems[db_state->list_index];
memmove(&db_state->list->elems[1],
&db_state->list->elems[0],
sizeof(entry) * db_state->list_index);
db_state->list->elems[0] = entry;
}
return 0;
}