diff options
author | Björn Gustavsson <[email protected]> | 2016-04-29 10:32:30 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-04-29 12:22:18 +0200 |
commit | 73b178c348c58783d470914d1cf105729d85f9bc (patch) | |
tree | 28dd51e798aad143d323ac13efbfcb0a461a4c4f /lib/kernel/src | |
parent | 61f421e356bd3eb659d7ba811905b2d3e1348348 (diff) | |
download | otp-73b178c348c58783d470914d1cf105729d85f9bc.tar.gz otp-73b178c348c58783d470914d1cf105729d85f9bc.tar.bz2 otp-73b178c348c58783d470914d1cf105729d85f9bc.zip |
Eliminate one call to filename:split/1
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/code_server.erl | 16 |
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. |