Add a isNicklistEmpty method to buffer model, speed up nicklist decision
Flattening the nicklist is really unnecessary. This method is 10x faster for short nicklists, and much faster for buffers with lots of users.
This commit is contained in:
parent
e9ca3ff5be
commit
739c4de0ef
2 changed files with 11 additions and 3 deletions
|
@ -975,8 +975,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
if ($scope.nonicklist) {
|
if ($scope.nonicklist) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Use flat nicklist to check if empty
|
// Check if nicklist is empty
|
||||||
if (ab.flatNicklist().length === 0) {
|
if (ab.isNicklistEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
10
js/models.js
10
js/models.js
|
@ -147,6 +147,13 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isNicklistEmpty = function() {
|
||||||
|
for (var obj in nicklist) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: pointer,
|
id: pointer,
|
||||||
fullName: fullName,
|
fullName: fullName,
|
||||||
|
@ -171,7 +178,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
history: history,
|
history: history,
|
||||||
addToHistory: addToHistory,
|
addToHistory: addToHistory,
|
||||||
getHistoryUp: getHistoryUp,
|
getHistoryUp: getHistoryUp,
|
||||||
getHistoryDown: getHistoryDown
|
getHistoryDown: getHistoryDown,
|
||||||
|
isNicklistEmpty: isNicklistEmpty
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue