aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-04-29 10:25:39 +0200
committerBjörn Gustavsson <[email protected]>2016-04-29 12:16:09 +0200
commit61f421e356bd3eb659d7ba811905b2d3e1348348 (patch)
treeea6cc59e7da37f914dbd61a92d8d6009d071313e /lib/kernel
parent684bc481c72701deb07ed61ee57b4e3cf7730d04 (diff)
downloadotp-61f421e356bd3eb659d7ba811905b2d3e1348348.tar.gz
otp-61f421e356bd3eb659d7ba811905b2d3e1348348.tar.bz2
otp-61f421e356bd3eb659d7ba811905b2d3e1348348.zip
Refactor get_name/1
Refactor get_name/1 to facilitate an optimization in the next commit.
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/code_server.erl29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index 2184a51396..7fefb40f10 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -615,18 +615,23 @@ exclude(Dir,Path) ->
%%
%%
get_name(Dir) ->
- get_name2(get_name1(Dir), []).
-
-get_name1(Dir) ->
- case lists:reverse(filename:split(Dir)) of
- ["ebin",DirName|_] -> DirName;
- [DirName|_] -> DirName;
- _ -> "" % No name !
- end.
-
-get_name2([$-|_],Acc) -> lists:reverse(Acc);
-get_name2([H|T],Acc) -> get_name2(T,[H|Acc]);
-get_name2(_,Acc) -> lists:reverse(Acc).
+ get_name_from_splitted(filename:split(Dir)).
+
+get_name_from_splitted([DirName,"ebin"]) ->
+ discard_after_hyphen(DirName);
+get_name_from_splitted([DirName]) ->
+ discard_after_hyphen(DirName);
+get_name_from_splitted([_|T]) ->
+ get_name_from_splitted(T);
+get_name_from_splitted([]) ->
+ "". %No name.
+
+discard_after_hyphen("-"++_) ->
+ [];
+discard_after_hyphen([H|T]) ->
+ [H|discard_after_hyphen(T)];
+discard_after_hyphen([]) ->
+ [].
check_path(Path) ->
PathChoice = init:code_path_choice(),