From 7d099a4fe0ceb6e9befa8a09939c19d087100bf4 Mon Sep 17 00:00:00 2001 From: Jesper Louis Andersen Date: Thu, 31 Jul 2008 00:54:12 +0200 Subject: [PATCH] Use filelib:wildcard rather than filelib:fold_files. It is 44 times faster. --- lib/etorrent-1.0/src/etorrent_dirwatcher.erl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/etorrent-1.0/src/etorrent_dirwatcher.erl b/lib/etorrent-1.0/src/etorrent_dirwatcher.erl index 1366994..9150647 100644 --- a/lib/etorrent-1.0/src/etorrent_dirwatcher.erl +++ b/lib/etorrent-1.0/src/etorrent_dirwatcher.erl @@ -72,12 +72,9 @@ code_change(_OldVsn, State, _Extra) -> %% Operations watch_directories(S) -> reset_marks(ets:first(etorrent_dirwatcher)), - F = fun(F, ok) -> - process_file(F), - ok - end, - ok = filelib:fold_files(S#state.dir, ".*\.torrent", false, - F, ok), + lists:foreach(fun process_file/1, + filelib:wildcard("*.torrent", S#state.dir)), + ets:safe_fixtable(etorrent_dirwatcher, true), start_stop(ets:first(etorrent_dirwatcher)), ets:safe_fixtable(etorrent_dirwatcher, false), -- 2.11.4.GIT