From c4565ebd3af11ea8a7a010470b01317b5a4fc230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 21 Feb 2013 13:29:53 +0100 Subject: 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. --- lib/asn1/src/asn1ct_name.erl | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/asn1/src/asn1ct_name.erl') 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}). -- cgit v1.2.3