diff options
author | Matthias Radestock <matthias@lshift.net> | 2009-07-01 13:23:08 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2009-07-01 13:23:08 +0100 |
commit | 127b4416974f7dc50f4466bc6c0a1560dbadc9f9 (patch) | |
tree | e28c189e75c66ca3045a5156e92bcdf69e1b3a9c /src | |
parent | ff661f30ed833804cb15a008476ff46b8de91d8a (diff) | |
download | rabbitmq-server-127b4416974f7dc50f4466bc6c0a1560dbadc9f9.tar.gz |
fold
Diffstat (limited to 'src')
-rw-r--r-- | src/rabbit_basic.erl | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl index c1964fb1..7184caba 100644 --- a/src/rabbit_basic.erl +++ b/src/rabbit_basic.erl @@ -90,15 +90,12 @@ properties(P) when is_list(P) -> %% Yes, this is O(length(P) * record_info(size, 'P_basic') / 2), %% i.e. slow. Use the definition of 'P_basic' directly if %% possible! - alist_to_properties(P). - -alist_to_properties([]) -> - #'P_basic'{}; -alist_to_properties([{Key, Value} | Rest]) -> - case indexof(record_info(fields, 'P_basic'), Key) of - 0 -> throw({unknown_P_basic_property_name, Key}); - N -> setelement(N, alist_to_properties(Rest), Value) - end. + lists:foldl(fun ({Key, Value}, Acc) -> + case indexof(record_info(fields, 'P_basic'), Key) of + 0 -> throw({unknown_P_basic_property_name, Key}); + N -> setelement(N, Acc, Value) + end + end, #'P_basic'{}, P). indexof(L, Element) -> indexof(L, Element, 1). |