# HG changeset patch # User unc0rr # Date 1223481455 0 # Node ID bffc7262e25e203dc5d14507056bfaab88e8c8d7 # Parent fedaae857a5059c270a14d0455f6597b6128779c Optimize list lookups a bit diff -r fedaae857a50 -r bffc7262e25e QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Wed Oct 08 15:55:23 2008 +0000 +++ b/QTfrontend/newnetclient.cpp Wed Oct 08 15:57:35 2008 +0000 @@ -300,22 +300,6 @@ return; } - if (lst[0] == "CONFIGURED") { - QStringList tmp = lst; - tmp.removeFirst(); - if(tmp.size() < 6) - { - qWarning("Net: Bad CONFIGURED message"); - return; - } - emit seedChanged(tmp[0]); - emit mapChanged(tmp[1]); - emit themeChanged(tmp[2]); - emit initHealthChanged(tmp[3].toUInt()); - emit turnTimeChanged(tmp[4].toUInt()); - emit fortsModeChanged(tmp[5].toInt() != 0); - return; - } if(lst[0]=="TEAM_ACCEPTED") { if(lst.size() < 3) diff -r fedaae857a50 -r bffc7262e25e netserver/HWProto.hs --- a/netserver/HWProto.hs Wed Oct 08 15:55:23 2008 +0000 +++ b/netserver/HWProto.hs Wed Oct 08 15:57:35 2008 +0000 @@ -4,7 +4,7 @@ import Data.List import Data.Word import Miscutils -import Maybe (fromMaybe, fromJust) +import Maybe import qualified Data.Map as Map answerBadCmd = [(clientOnly, ["ERROR", "Bad command, state or incorrect parameter"])] @@ -61,7 +61,7 @@ else (modifyClient client{nick = newNick}, noChangeRooms, answerNick newNick) where - haveSameNick = not . null $ filter (\cl -> newNick == nick cl) clients + haveSameNick = isJust $ find (\cl -> newNick == nick cl) clients handleCmd_noInfo client _ _ ["PROTO", protoNum] = if protocol client > 0 then @@ -87,7 +87,7 @@ else (modifyClient client{room = newRoom, isMaster = True}, addRoom (RoomInfo newRoom roomPassword (protocol client) [] Map.empty), answerJoined $ nick client) where - haveSameRoom = not . null $ filter (\room -> newRoom == name room) rooms + haveSameRoom = isJust $ find (\room -> newRoom == name room) rooms handleCmd_noRoom client clients rooms ["CREATE", newRoom] = handleCmd_noRoom client clients rooms ["CREATE", newRoom, ""] @@ -100,7 +100,7 @@ else (modifyClient client{room = roomName}, noChangeRooms, (answerJoined $ nick client) ++ answerNicks ++ answerFullConfig joinRoom) where - noSuchRoom = null $ filter (\room -> roomName == name room) rooms + noSuchRoom = isNothing $ find (\room -> roomName == name room) rooms answerNicks = [(clientOnly, ["JOINED"] ++ (map nick $ filter (\ci -> room ci == roomName) clients))] joinRoom = roomByName roomName rooms