aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-02-21 13:29:53 +0100
committerBjörn Gustavsson <[email protected]>2013-05-31 14:52:13 +0200
commitc4565ebd3af11ea8a7a010470b01317b5a4fc230 (patch)
tree8d1b09e843288d0ad6f44e2a895292a6a2118d1c
parentde80abaac0af1ee62b69a405a5a36ecd601fab7c (diff)
downloadotp-c4565ebd3af11ea8a7a010470b01317b5a4fc230.tar.gz
otp-c4565ebd3af11ea8a7a010470b01317b5a4fc230.tar.bz2
otp-c4565ebd3af11ea8a7a010470b01317b5a4fc230.zip
asnct1_name: Optimize clean/1
clean/1 is used quite lot; while not a bottleneck it does seem unnecessary to stop and start the name server just to clear the variables. Since the change to clean/1 makes stop/1 unused, we can remove it.
-rw-r--r--lib/asn1/src/asn1ct_name.erl15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/asn1/src/asn1ct_name.erl b/lib/asn1/src/asn1ct_name.erl
index 9711ea6d31..4674048a13 100644
--- a/lib/asn1/src/asn1ct_name.erl
+++ b/lib/asn1/src/asn1ct_name.erl
@@ -21,7 +21,6 @@
%%-compile(export_all).
-export([start/0,
- stop/0,
curr/1,
clear/0,
active/1,
@@ -43,13 +42,11 @@ start() ->
already_started
end.
-stop() ->
- req(stop),
- erase(?MODULE).
-
name_server_loop({Ref, Parent} = Monitor,Vars) ->
%% io:format("name -- ~w~n",[Vars]),
receive
+ {_From,clear} ->
+ name_server_loop(Monitor, []);
{From,{current,Variable}} ->
From ! {?MODULE,get_curr(Vars,Variable)},
name_server_loop(Monitor,Vars);
@@ -61,10 +58,8 @@ name_server_loop({Ref, Parent} = Monitor,Vars) ->
{From,{next,Variable}} ->
From ! {?MODULE,get_next(Vars,Variable)},
name_server_loop(Monitor,Vars);
- {'DOWN', Ref, process, Parent, Reason} ->
- exit(Reason);
- {From,stop} ->
- From ! {?MODULE,stopped}
+ {'DOWN', Ref, process, Parent, Reason} ->
+ exit(Reason)
end.
active(V) ->
@@ -88,7 +83,7 @@ cast(Req) ->
get(?MODULE) ! {self(), Req},
ok.
-clear() -> stop(), start().
+clear() -> cast(clear).
curr(V) -> req({current,V}).
new(V) -> cast({new,V}).