diff options
| author | Simon MacMullen <simon@lshift.net> | 2008-11-28 11:00:04 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@lshift.net> | 2008-11-28 11:00:04 +0000 |
| commit | a4c764da90e0bceaf73300bab594146482a85bfa (patch) | |
| tree | 8b53ea789fbf84ebd85489fc2cef8ecd2dfaa3bb /src | |
| parent | 926a90b233a5804677f88472b7490fdbd6ab413d (diff) | |
| download | rabbitmq-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.erl | 4 |
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. |
