From ea2481f1fdec3ce9f510201130eca51ab553fa71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 27 Nov 2015 16:06:41 +0100 Subject: erl_prim_loader: Avoid making absolute paths We don't need absolute paths unless we are dealing with archives. Since it is not free to turn a relative path absolute (we will need a call to prim_file to fetch the current directory), it's better to delay the call to absname/1 until we are sure it's needed. --- erts/preloaded/src/erl_prim_loader.erl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/erts/preloaded/src/erl_prim_loader.erl b/erts/preloaded/src/erl_prim_loader.erl index dbb658c904..91ef2bd6d0 100644 --- a/erts/preloaded/src/erl_prim_loader.erl +++ b/erts/preloaded/src/erl_prim_loader.erl @@ -1202,11 +1202,7 @@ path_join([Path],Acc) -> path_join([Path|Paths],Acc) -> path_join(Paths,"/" ++ reverse(Path) ++ Acc). -name_split(ArchiveFile, File0) -> - File = absname(File0), - do_name_split(ArchiveFile, File). - -do_name_split(undefined, File) -> +name_split(undefined, File) -> %% Ignore primary archive RevExt = reverse(init:archive_extension()), case archive_split(File, RevExt, []) of @@ -1215,12 +1211,13 @@ do_name_split(undefined, File) -> Archive -> Archive end; -do_name_split(ArchiveFile, File) -> +name_split(ArchiveFile, File0) -> %% Look first in primary archive + File = absname(File0), case string_match(real_path(File), ArchiveFile, []) of no_match -> %% Archive or plain file - do_name_split(undefined, File); + name_split(undefined, File); {match, _RevPrimArchiveFile, FileInArchive} -> %% Primary archive {archive, ArchiveFile, FileInArchive} @@ -1240,7 +1237,7 @@ archive_split("/"++File, RevExt, Acc) -> false -> archive_split(File, RevExt, [$/|Acc]); true -> - ArchiveFile = reverse(Acc), + ArchiveFile = absname(reverse(Acc)), {archive, ArchiveFile, File} end; archive_split([H|T], RevExt, Acc) -> @@ -1250,7 +1247,7 @@ archive_split([], RevExt, Acc) -> false -> no_split; true -> - ArchiveFile = reverse(Acc), + ArchiveFile = absname(reverse(Acc)), {archive, ArchiveFile, []} end. -- cgit v1.2.3