Small optimization (use partition instead of two filters with opposite predicates)
--- a/netserver/HWProto.hs Thu Oct 09 16:03:27 2008 +0000
+++ b/netserver/HWProto.hs Thu Oct 09 16:05:01 2008 +0000
@@ -57,10 +57,11 @@
else if isMaster client then
(noChangeClients, removeRoom (room client), answerQuit ++ answerAbandoned) -- core disconnects clients on ROOMABANDONED answer
else
- (noChangeClients, modifyRoom clRoom{teams = filter (\t -> teamowner t /= nick client) $ teams clRoom}, answerQuit ++ (answerQuitInform $ nick client) ++ answerRemoveClientTeams)
+ (noChangeClients, modifyRoom clRoom{teams = othersTeams}, answerQuit ++ (answerQuitInform $ nick client) ++ answerRemoveClientTeams)
where
clRoom = roomByName (room client) rooms
- answerRemoveClientTeams = map (\tn -> (othersInRoom, ["REMOVE_TEAM", teamname tn])) $ filter (\t -> teamowner t == nick client) $ teams clRoom
+ answerRemoveClientTeams = map (\tn -> (othersInRoom, ["REMOVE_TEAM", teamname tn])) clientTeams
+ (clientTeams, othersTeams) = partition (\t -> teamowner t == nick client) $ teams clRoom
-- check state and call state-dependent commmand handlers