diff options
author | Björn Gustavsson <[email protected]> | 2014-02-20 12:30:27 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-02-20 12:30:27 +0100 |
commit | 39c18117df7cb5393fb0164c9aded020941fbddb (patch) | |
tree | a8dd9ecd10bcb9126f969a7213d5735f56709c62 /lib/asn1/src/asn1ct_table.erl | |
parent | 4c538e1a857d3dce7cbb8358f9ddd08b25db166e (diff) | |
parent | 5c12db17fea6de6f3fc3ce16a7159b6f71ea92f4 (diff) | |
download | otp-39c18117df7cb5393fb0164c9aded020941fbddb.tar.gz otp-39c18117df7cb5393fb0164c9aded020941fbddb.tar.bz2 otp-39c18117df7cb5393fb0164c9aded020941fbddb.zip |
Merge branch 'bjorn/asn1/cleanup/OTP-11727'
* bjorn/asn1/cleanup/OTP-11727:
asn1ct_check: Use a return value to silence a dialyzer warning
asn1ct_check: Remove useless call to check_integer/3
asn1ct_check: Correct error handling for illegal OCTET STRING values
asn1ct: Silence dialyzer warnings for unmatched returns
asn1ct_table: Remove unused flexibility in table creation
asn1ct_table: Silence a dialyzer warning for unmatched return
asn1ct_gen: Silence dialyzer warnings for unmatched returns
asn1ct_value: Silence a dialyzer warning for unmatched return
asn1ct_tok: Check return value from file:close/1
Diffstat (limited to 'lib/asn1/src/asn1ct_table.erl')
-rw-r--r-- | lib/asn1/src/asn1ct_table.erl | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/lib/asn1/src/asn1ct_table.erl b/lib/asn1/src/asn1ct_table.erl index a5eb6d0413..2eca80eda3 100644 --- a/lib/asn1/src/asn1ct_table.erl +++ b/lib/asn1/src/asn1ct_table.erl @@ -22,34 +22,25 @@ %% Table abstraction module for ASN.1 compiler -export([new/1]). --export([new/2]). -export([new_reuse/1]). --export([new_reuse/2]). -export([exists/1]). -export([size/1]). -export([insert/2]). -export([lookup/2]). -export([match/2]). -export([to_list/1]). --export([delete/1]). % TODO: Remove (since we run in a separate process) +-export([delete/1]). -%% Always creates a new table -new(Table) -> new(Table, []). -new(Table, Options) -> - TableId = case get(Table) of - undefined -> - ets:new(Table, Options); - _ -> - delete(Table), - ets:new(Table, Options) - end, +%% Always create a new table. +new(Table) -> + undefined = get(Table), %Assertion. + TableId = ets:new(Table, []), put(Table, TableId). -%% Only create it if it doesn't exist yet -new_reuse(Table) -> new_reuse(Table, []). -new_reuse(Table, Options) -> - not exists(Table) andalso new(Table, Options). +%% Only create it if it doesn't exist yet. +new_reuse(Table) -> + not exists(Table) andalso new(Table). exists(Table) -> get(Table) =/= undefined. @@ -63,14 +54,17 @@ match(Table, MatchSpec) -> ets:match(get(Table), MatchSpec). to_list(Table) -> ets:tab2list(get(Table)). +%% Deleting tables is no longer strictly necessary since each compilation +%% runs in separate process, but it will reduce memory consumption +%% especially when many compilations are run in parallel. + delete(Tables) when is_list(Tables) -> [delete(T) || T <- Tables], true; delete(Table) when is_atom(Table) -> - case get(Table) of + case erase(Table) of undefined -> true; TableId -> - ets:delete(TableId), - erase(Table) + ets:delete(TableId) end. |