fixup! Win32: add a cache below mingw's lstat and dirent implementations

The fscache_clear() function used to be O(n^2). But we can easily make
it O(n) instead.

Update fscache_clear to be O(n) instead of O(n^2) by using inter_next
instead of starting from the begining each time with iter_first. While
at it, also disallow rehashing while removing the entries.

This speeds up a simple `git commit -m foo` when fscache is enabled
(because fscache_clear() is called implicitly by preload_index()).

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Ben Peart
2017-05-26 00:55:47 +00:00
committed by Johannes Schindelin
parent 51efe4db88
commit bda7f0728a

View File

@@ -257,10 +257,13 @@ static void fscache_clear(void)
{
struct hashmap_iter iter;
struct fsentry *fse;
while ((fse = hashmap_iter_first(&map, &iter))) {
hashmap_disallow_rehash(&map, 1);
hashmap_iter_init(&map, &iter);
while ((fse = hashmap_iter_next(&iter))) {
fscache_remove(fse);
fsentry_release(fse);
}
hashmap_disallow_rehash(&map, 0);
}
/*