aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Carlsson <[email protected]>2016-11-22 15:33:14 +0100
committerRichard Carlsson <[email protected]>2016-11-22 15:33:14 +0100
commita834d721e5047c5c43a8ede249fdf6711234ff1b (patch)
tree2dc6c5f86317fae7cf6472b93a3ae5bbbce83094
parentc7e5cf8e259956120c07206c4e7df235b129cb56 (diff)
downloadotp-a834d721e5047c5c43a8ede249fdf6711234ff1b.tar.gz
otp-a834d721e5047c5c43a8ede249fdf6711234ff1b.tar.bz2
otp-a834d721e5047c5c43a8ede249fdf6711234ff1b.zip
Handle prefetched paths
-rw-r--r--lib/kernel/src/code.erl9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index bb19d6716d..0ad0676f98 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -738,11 +738,16 @@ where_is_file(File) when is_list(File) ->
Path = get_path(),
where_is_file(Path, File).
--spec where_is_file(Path :: file:filename(), Filename :: file:filename()) ->
- file:filename() | 'non_existing'.
+%% To avoid unnecessary work when looking at many modules, this also
+%% accepts pairs of directories and pre-fetched contents in the path
+-spec where_is_file(Path :: [Dir|{Dir,Files}], Filename :: file:filename()) ->
+ 'non_existing' | file:filename() when
+ Dir :: file:filename(), Files :: [file:filename()].
where_is_file([], _) ->
non_existing;
+where_is_file([{Path, Files}|Tail], File) ->
+ where_is_file(Tail, File, Path, Files);
where_is_file([Path|Tail], File) ->
case erl_prim_loader:list_dir(Path) of
{ok,Files} ->