Skip to content
Permalink
Browse files
cache field names
  • Loading branch information
bartekgorny committed Jul 25, 2018
1 parent 4a01261 commit 5177ac724d732df5e47e6b983576165df31a2975
Showing 2 changed files with 5 additions and 6 deletions.
@@ -87,7 +87,7 @@ make_list_entry({{Name, _}, Fields, Module, Limits}) ->
[] -> all;
Other -> Other
end,
{Module, Name, field_names(Fields), FmtLimit}.
{Module, Name, Fields, FmtLimit}.

import(Module, ResultList) ->
ensure_table_exists(),
@@ -141,7 +141,7 @@ ensure_table_exists() ->
ets_table_name() -> recon_record_definitions.

rec_info({Name, Fields}, Module) ->
{{Name, length(Fields)}, Fields, Module, []}.
{{Name, length(Fields)}, field_names(Fields), Module, []}.

rem_for_module({_, _, Module, _} = Rec, Module) ->
ets:delete_object(ets_table_name(), Rec);
@@ -182,8 +182,7 @@ format_record(Rec, {{Name, Arity}, Fields, _, Limits}) ->
case tuple_size(Rec) of
ExpectedLength ->
[_ | Values] = tuple_to_list(Rec),
FieldNames = field_names(Fields),
List = lists:zip(FieldNames, Values),
List = lists:zip(Fields, Values),
LimitedList = apply_limits(List, Limits),
"#" ++ atom_to_list(Name) ++ "{"
++ lists:join(", ", [format_kv(Key, Val) || {Key, Val} <- LimitedList]) ++ "}";
@@ -60,7 +60,7 @@ lists_and_limits(_Config) ->
{records1,another,[ddd,eee,fff], [ddd, eee]} = hd(recon_rec:get_list()),
recon_rec:limit(another, 3, all),
{records1,another,[ddd,eee,fff], all} = hd(recon_rec:get_list()),
recon_rec:clear(record2),
recon_rec:clear(records2),
{error, record_unknown} = recon_rec:limit(another, 4, all),
ok.

@@ -74,4 +74,4 @@ no_record(Name, Count) ->

check_first_field(F, Rec) ->
{_, Fields, _, _} = Rec,
{record_field, _, {atom, _, F}} = hd(Fields).
F = hd(Fields).

0 comments on commit 5177ac7

Please sign in to comment.