summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@lshift.net>2008-11-28 11:00:04 +0000
committerSimon MacMullen <simon@lshift.net>2008-11-28 11:00:04 +0000
commita4c764da90e0bceaf73300bab594146482a85bfa (patch)
tree8b53ea789fbf84ebd85489fc2cef8ecd2dfaa3bb /src
parent926a90b233a5804677f88472b7490fdbd6ab413d (diff)
downloadrabbitmq-server-git-a4c764da90e0bceaf73300bab594146482a85bfa.tar.gz
Remove use of list append, making it O(n) rather than O(n^2).
Of course in this case n = 1.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_memsup_linux.erl4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rabbit_memsup_linux.erl b/src/rabbit_memsup_linux.erl
index 10c8d7e049..6f46bd4b8d 100644
--- a/src/rabbit_memsup_linux.erl
+++ b/src/rabbit_memsup_linux.erl
@@ -138,11 +138,11 @@ read_proc_file(File) ->
{ok, IoDevice} = file:open(File, [read, raw]),
Res = read_proc_file(IoDevice, []),
file:close(IoDevice),
- Res.
+ lists:flatten(lists:reverse(Res)).
read_proc_file(IoDevice, Acc) ->
case file:read(IoDevice, ?BUFFER_SIZE) of
- {ok, Res} -> read_proc_file(IoDevice, Acc ++ Res);
+ {ok, Res} -> read_proc_file(IoDevice, [Res | Acc]);
eof -> Acc
end.