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 | 092af4767e05b179ae7e00e27471c2289b79fb00 (patch) | |
| tree | e28c189e75c66ca3045a5156e92bcdf69e1b3a9c | |
| parent | 2da0708dd41a59562cc133022f1493b81a49a114 (diff) | |
| download | rabbitmq-server-git-092af4767e05b179ae7e00e27471c2289b79fb00.tar.gz | |
fold
| -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 c1964fb1e8..7184caba29 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). |
