Store clients as Map rather than array
Summary: Refactor clients storage: array -> map. A lot of logic looks up clients by their id, which is currently done with an array.find operation, which is pretty inefficient. This diff changes it to a map, that is pretty important, as in the next diff the decoupled client message handing will need to find the client again for every message that arrives. Reviewed By: timur-valiev Differential Revision: D31303536 fbshipit-source-id: ca3f540a3de7665930d2354436d37cb0fbfd5546
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c9a34d3cc2
commit
026f8fc308
@@ -144,7 +144,7 @@ export default async (store: Store, logger: Logger) => {
|
||||
|
||||
export async function handleClientConnected(store: Store, client: Client) {
|
||||
const {connections} = store.getState();
|
||||
const existingClient = connections.clients.find((c) => c.id === client.id);
|
||||
const existingClient = connections.clients.get(client.id);
|
||||
|
||||
if (existingClient) {
|
||||
existingClient.destroy();
|
||||
|
||||
Reference in New Issue
Block a user