Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
7841-Avoid-listing-code-path-directories.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 7841-Avoid-listing-code-path-directories.patch of Package erlang
From 20f3c11c5f3ab7741049d983ea7353240181b79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= <jose.valim@dashbit.co> Date: Mon, 2 Oct 2023 18:40:40 +0200 Subject: [PATCH] Avoid listing code path directories If a code path directory has too many .beam files, then `list_dir/1` becomes a quite expensive operation. With this commit, code:where_is_file/2 and code:which/1 attempt to directly find a file, instead of listing the directory. --- lib/kernel/src/code.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl index 32381a88d2..0148d9c7aa 100644 --- a/lib/kernel/src/code.erl +++ b/lib/kernel/src/code.erl @@ -859,8 +859,7 @@ which(Module, Path) when is_atom(Module) -> File = atom_to_list(Module) ++ objfile_extension(), where_is_file(Path, File). -%% Search the code path for a specific file. Try to locate -%% it in the code path cache if possible. +%% Search the code path for a specific file. -spec where_is_file(Filename) -> non_existing | Absname when Filename :: file:filename(), @@ -880,9 +879,10 @@ where_is_file([], _) -> 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} -> - where_is_file(Tail, File, Path, Files); + Full = filename:append(Path, File), + case erl_prim_loader:read_file_info(Full) of + {ok,_} -> + Full; _Error -> where_is_file(Tail, File) end. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor