aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Oliver <[email protected]>2012-01-31 19:28:34 +0000
committerPaul Oliver <[email protected]>2012-01-31 19:29:56 +0000
commit697170b4968373d70193c4719ef2c4d8bf810ceb (patch)
tree74476937f5205d10f10792121111dfb4e97d6a41 /src
parent0c3cf802b429258e2a6ff924156c8d330de5c7e1 (diff)
downloadcowboy-697170b4968373d70193c4719ef2c4d8bf810ceb.tar.gz
cowboy-697170b4968373d70193c4719ef2c4d8bf810ceb.tar.bz2
cowboy-697170b4968373d70193c4719ef2c4d8bf810ceb.zip
Remove call to queue:len/1
queue:len/1 is O(len(Q)) queue:out/1 is O(1) amortized, O(len(Q)) worst case Replace with a pattern match
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_listener.erl11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/cowboy_listener.erl b/src/cowboy_listener.erl
index b12e059..de81cbe 100644
--- a/src/cowboy_listener.erl
+++ b/src/cowboy_listener.erl
@@ -202,11 +202,10 @@ remove_pid(Pid, Pools, ReqsTable, Queue) ->
{Pool, NbConns} = lists:keyfind(Pool, 1, Pools),
Pools2 = [{Pool, NbConns - 1}|lists:keydelete(Pool, 1, Pools)],
ets:delete(ReqsTable, Pid),
- case queue:len(Queue) of
- 0 ->
- {Pools2, Queue};
- _ ->
- {{value, Client}, Queue2} = queue:out(Queue),
+ case queue:out(Queue) of
+ {{value, Client}, Queue2} ->
gen_server:reply(Client, ok),
- {Pools2, Queue2}
+ {Pools2, Queue2};
+ _ ->
+ {Pools2, Queue}
end.