aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1_db.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-12-16 10:10:01 +0100
committerBjörn Gustavsson <[email protected]>2015-01-12 12:22:59 +0100
commitac5c60b0de2ef93a99f6c39f3e251f526f303964 (patch)
tree755db42699b6ba0a53cd65d853e79f8d02c13944 /lib/asn1/src/asn1_db.erl
parent92f5fe1fdd4982a48fe903b8d864501cc3e7e6c2 (diff)
downloadotp-ac5c60b0de2ef93a99f6c39f3e251f526f303964.tar.gz
otp-ac5c60b0de2ef93a99f6c39f3e251f526f303964.tar.bz2
otp-ac5c60b0de2ef93a99f6c39f3e251f526f303964.zip
Reimplement storeindb/2 to avoid excessive process communication
As currently implemented, there is one call to asn1db:dbget() and asn1db:dbput() for each type/value definitions in an ASN.1 specification. If we check for duplicate definitions locally, we can send all definitions in a single call.
Diffstat (limited to 'lib/asn1/src/asn1_db.erl')
-rw-r--r--lib/asn1/src/asn1_db.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/asn1/src/asn1_db.erl b/lib/asn1/src/asn1_db.erl
index 48d9dd16d7..5577969727 100644
--- a/lib/asn1/src/asn1_db.erl
+++ b/lib/asn1/src/asn1_db.erl
@@ -19,7 +19,8 @@
%%
-module(asn1_db).
--export([dbstart/1,dbnew/2,dbload/1,dbload/3,dbsave/2,dbput/3,dbget/2]).
+-export([dbstart/1,dbnew/2,dbload/1,dbload/3,dbsave/2,dbput/2,
+ dbput/3,dbget/2]).
-export([dbstop/0]).
-record(state, {parent, monitor, includes, table}).
@@ -44,6 +45,7 @@ dbload(Module) ->
dbnew(Module, Erule) -> req({new, Module, Erule}).
dbsave(OutFile, Module) -> cast({save, OutFile, Module}).
dbput(Module, K, V) -> cast({set, Module, K, V}).
+dbput(Module, Kvs) -> cast({set, Module, Kvs}).
dbget(Module, K) -> req({get, Module, K}).
dbstop() -> Resp = req(stop), erase(?MODULE), Resp.
@@ -82,6 +84,10 @@ loop(#state{parent = Parent, monitor = MRef, table = Table,
[{_, Modtab}] = ets:lookup(Table, Mod),
ets:insert(Modtab, {K2, V}),
loop(State);
+ {set, Mod, Kvs} ->
+ [{_, Modtab}] = ets:lookup(Table, Mod),
+ ets:insert(Modtab, Kvs),
+ loop(State);
{From, {get, Mod, K2}} ->
%% XXX If there is no information for Mod, get_table/3
%% will attempt to load information from an .asn1db