소스 검색

BETA: Strings should be avoided as key in maps unless you need the key this way. The hash of the string will just do fine, and saves a hell lot of RAM.

Nik 13 년 전
부모
커밋
338d518657
1개의 변경된 파일7개의 추가작업 그리고 8개의 파일을 삭제
  1. 7 8
      L2J_Server_BETA/java/com/l2jserver/gameserver/LoginServerThread.java

+ 7 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/LoginServerThread.java

@@ -33,13 +33,11 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
 import javolution.util.FastList;
-import javolution.util.FastMap;
 
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
@@ -70,6 +68,7 @@ import com.l2jserver.gameserver.network.loginserverpackets.RequestCharacters;
 import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
 import com.l2jserver.gameserver.network.serverpackets.LoginFail;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.util.L2TIntObjectHashMap;
 import com.l2jserver.util.Util;
 import com.l2jserver.util.crypt.NewCrypt;
 import com.l2jserver.util.network.BaseSendablePacket;
@@ -109,7 +108,7 @@ public class LoginServerThread extends Thread
 	private final boolean _reserveHost;
 	private int _maxPlayer;
 	private final List<WaitingClient> _waitingClients;
-	private final Map<String, L2GameClient> _accountsInGameServer;
+	private final L2TIntObjectHashMap<L2GameClient> _accountsInGameServer;
 	private int _status;
 	private String _serverName;
 	private final String[] _subnets;
@@ -136,7 +135,7 @@ public class LoginServerThread extends Thread
 		_subnets = Config.GAME_SERVER_SUBNETS;
 		_hosts = Config.GAME_SERVER_HOSTS;
 		_waitingClients = new FastList<WaitingClient>();
-		_accountsInGameServer = new FastMap<String, L2GameClient>().shared();
+		_accountsInGameServer = new L2TIntObjectHashMap<L2GameClient>();
 		_maxPlayer = Config.MAXIMUM_ONLINE_USERS;
 	}
 	
@@ -337,7 +336,7 @@ public class LoginServerThread extends Thread
 									_log.warning("Session key is not correct. Closing connection for account " + wcToRemove.account + ".");
 									//wcToRemove.gameClient.getConnection().sendPacket(new LoginFail(LoginFail.SYSTEM_ERROR_LOGIN_LATER));
 									wcToRemove.gameClient.close(new LoginFail(LoginFail.SYSTEM_ERROR_LOGIN_LATER));
-									_accountsInGameServer.remove(wcToRemove.account);
+									_accountsInGameServer.remove(wcToRemove.account.hashCode());
 								}
 								_waitingClients.remove(wcToRemove);
 							}
@@ -450,13 +449,13 @@ public class LoginServerThread extends Thread
 		}
 		finally
 		{
-			_accountsInGameServer.remove(account);
+			_accountsInGameServer.remove(account.hashCode());
 		}
 	}
 	
 	public void addGameServerLogin(String account, L2GameClient client)
 	{
-		_accountsInGameServer.put(account, client);
+		_accountsInGameServer.put(account.hashCode(), client);
 	}
 	
 	public void sendAccessLevel(String account, int level)
@@ -522,7 +521,7 @@ public class LoginServerThread extends Thread
 	
 	public void doKickPlayer(String account)
 	{
-		L2GameClient client = _accountsInGameServer.get(account);
+		L2GameClient client = _accountsInGameServer.get(account.hashCode());
 		if (client != null)
 		{
 			LogRecord record = new LogRecord(Level.WARNING, "Kicked by login");