Speed up join by avoiding quadratic userlist code
At some point the entire user presence logic needs to be refactored for efficiency, but this at least gives a huge reduction in first page load time for large channels.
This commit is contained in:
parent
3413c3bdaa
commit
fa49921866
|
@ -487,13 +487,13 @@ Callbacks = {
|
|||
userlist: function(data) {
|
||||
$(".userlist_item").remove();
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList(data[i]);
|
||||
CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList(data[i], false);
|
||||
}
|
||||
sortUserlist();
|
||||
},
|
||||
|
||||
addUser: function(data) {
|
||||
CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList(data);
|
||||
CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList(data, true);
|
||||
sortUserlist();
|
||||
},
|
||||
|
||||
|
|
|
@ -3364,11 +3364,13 @@ CyTube.ui.changeVideoWidth = function uiChangeVideoWidth(direction) {
|
|||
handleVideoResize();
|
||||
};
|
||||
|
||||
CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList = function (data) {
|
||||
var user = findUserlistItem(data.name);
|
||||
// Remove previous instance of user, if there was one
|
||||
if(user !== null)
|
||||
user.remove();
|
||||
CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList = function (data, removePrev) {
|
||||
if (removePrev) {
|
||||
var user = findUserlistItem(data.name);
|
||||
// Remove previous instance of user, if there was one
|
||||
if(user !== null)
|
||||
user.remove();
|
||||
}
|
||||
var div = $("<div/>")
|
||||
.addClass("userlist_item");
|
||||
var icon = $("<span/>").appendTo(div);
|
||||
|
|
Loading…
Reference in a new issue