Small optimization (use partition instead of two filters with opposite predicates)
authorunc0rr
Thu, 09 Oct 2008 16:05:01 +0000
changeset 1335 c795cbc752c1
parent 1334 b58afaadf7ae
child 1336 4e88eccbe7f6
Small optimization (use partition instead of two filters with opposite predicates)
netserver/HWProto.hs
--- 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