diff options
author | Björn Gustavsson <[email protected]> | 2014-01-31 10:57:17 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-01-31 16:04:30 +0100 |
commit | f14ab1100c4fc19b8446f732bac60429d181a2f3 (patch) | |
tree | 84415db4b188306ae877589607e7f7d21b751cfb /lib/asn1/src | |
parent | 17411317c3bfe8b0c557db5cb388e1874706b13a (diff) | |
download | otp-f14ab1100c4fc19b8446f732bac60429d181a2f3.tar.gz otp-f14ab1100c4fc19b8446f732bac60429d181a2f3.tar.bz2 otp-f14ab1100c4fc19b8446f732bac60429d181a2f3.zip |
asn1ct_table: Remove unused flexibility in table creation
Unused flexibility complicates the code and can hide bugs.
new/1 is never called with a table name that already exists, so
we should remove the code that allows for that. That will increase
the coverage of asn1ct_table to 100%.
Also remove the new/2 and new_reuse/2 functions which are never
called externally.
Diffstat (limited to 'lib/asn1/src')
-rw-r--r-- | lib/asn1/src/asn1ct_table.erl | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/asn1/src/asn1ct_table.erl b/lib/asn1/src/asn1ct_table.erl index 139267d32b..2eca80eda3 100644 --- a/lib/asn1/src/asn1ct_table.erl +++ b/lib/asn1/src/asn1ct_table.erl @@ -22,9 +22,7 @@ %% 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]). @@ -34,22 +32,15 @@ -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. |