aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-04-29 10:32:30 +0200
committerBjörn Gustavsson <[email protected]>2016-04-29 12:22:18 +0200
commit73b178c348c58783d470914d1cf105729d85f9bc (patch)
tree28dd51e798aad143d323ac13efbfcb0a461a4c4f /lib/kernel
parent61f421e356bd3eb659d7ba811905b2d3e1348348 (diff)
downloadotp-73b178c348c58783d470914d1cf105729d85f9bc.tar.gz
otp-73b178c348c58783d470914d1cf105729d85f9bc.tar.bz2
otp-73b178c348c58783d470914d1cf105729d85f9bc.zip
Eliminate one call to filename:split/1
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/code_server.erl16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index 7fefb40f10..d1c603cef3 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -779,7 +779,7 @@ init_namedb(Path) ->
Db.
init_namedb([P|Path], Db) ->
- insert_name(P, Db),
+ insert_dir(P, Db),
init_namedb(Path, Db);
init_namedb([], _) ->
ok.
@@ -792,14 +792,18 @@ clear_namedb([], _) ->
ok.
-endif.
-insert_name(Dir, Db) ->
- case get_name(Dir) of
- Dir -> false;
- Name -> insert_name(Name, Dir, Db)
- end.
+%% Dir must be a complete pathname (not only a name).
+insert_dir(Dir, Db) ->
+ Splitted = filename:split(Dir),
+ Name = get_name_from_splitted(Splitted),
+ AppDir = filename:join(del_ebin_1(Splitted)),
+ do_insert_name(Name, AppDir, Db).
insert_name(Name, Dir, Db) ->
AppDir = del_ebin(Dir),
+ do_insert_name(Name, AppDir, Db).
+
+do_insert_name(Name, AppDir, Db) ->
{Base, SubDirs} = archive_subdirs(AppDir),
ets:insert(Db, {Name, AppDir, Base, SubDirs}),
true.