mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-09 21:46:08 -05:00
Omit private rooms from Rooms.global.chatRooms
Rooms.global.chatRooms is a cached list of chat rooms, useful since Rooms.rooms on Main has thousands of rooms on average, while less than 100 of them are chat rooms. A scan through the code reveals that private rooms are never used (except for .isPrivate === 'voice') when we need .chatRooms, so we can omit them to make the cache even smaller/faster. This is a fairly minor optimization (we have fewer private rooms than public rooms, total) and private rooms are omitted lazily (only upon server restart) because we have to check .isPrivate for the === 'voice' case anyway.
This commit is contained in:
parent
d89a77ac87
commit
7925516d13
|
|
@ -247,6 +247,9 @@ var commands = exports.commands = {
|
|||
delete room.chatRoomData.isPrivate;
|
||||
Rooms.global.writeChatRoomData();
|
||||
}
|
||||
if (Rooms.global.chatRooms.indexOf(room) < 0) {
|
||||
Rooms.global.chatRooms.push(room);
|
||||
}
|
||||
} else {
|
||||
room.isPrivate = setting;
|
||||
this.addModCommand("" + user.name + " made this room " + (setting === true ? 'secret' : setting) + ".");
|
||||
|
|
|
|||
4
rooms.js
4
rooms.js
|
|
@ -197,6 +197,8 @@ var GlobalRoom = (function () {
|
|||
}];
|
||||
}
|
||||
|
||||
// cached list of chat rooms for the room list
|
||||
// usually does not contain private rooms, but no guarantees
|
||||
this.chatRooms = [];
|
||||
|
||||
this.autojoin = []; // rooms that users autojoin upon connecting
|
||||
|
|
@ -214,7 +216,7 @@ var GlobalRoom = (function () {
|
|||
aliases[room.aliases[a]] = room;
|
||||
}
|
||||
}
|
||||
this.chatRooms.push(room);
|
||||
if (!room.isPrivate || room.isPrivate === 'voice') this.chatRooms.push(room);
|
||||
if (room.autojoin) this.autojoin.push(id);
|
||||
if (room.staffAutojoin) this.staffAutojoin.push(id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user