Improve Unread Count performances.

docuemnt.title setter is slow. This is about 10 times faster.
This commit is contained in:
Nicolas Stepien 2012-03-07 18:56:57 +01:00
parent 19d0617f4c
commit 3232671980
2 changed files with 23 additions and 2 deletions

View File

@ -3509,11 +3509,22 @@
Unread.replies = Unread.replies.slice(i);
return Unread.update();
},
setTitle: function(count) {
if (this.scheduled) {
clearTimeout(this.scheduled);
delete Unread.scheduled;
this.setTitle(count);
return;
}
return this.scheduled = setTimeout((function() {
return d.title = "(" + count + ") " + Unread.title;
}), 5);
},
update: function(forceUpdate) {
var count;
if (!g.REPLY) return;
count = this.replies.length;
if (conf['Unread Count']) d.title = "(" + count + ") " + this.title;
if (conf['Unread Count']) this.setTitle(count);
if (!(conf['Unread Favicon'] && (count < 2 || forceUpdate))) return;
Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"];
return $.add(d.head, Favicon.el);

View File

@ -2877,13 +2877,23 @@ Unread =
Unread.replies = Unread.replies[i..]
Unread.update()
setTitle: (count) ->
if @scheduled
clearTimeout @scheduled
delete Unread.scheduled
@setTitle count
return
@scheduled = setTimeout (->
d.title = "(#{count}) #{Unread.title}"
), 5
update: (forceUpdate) ->
return unless g.REPLY
count = @replies.length
if conf['Unread Count']
d.title = "(#{count}) #{@title}"
@setTitle count
unless conf['Unread Favicon'] and (count < 2 or forceUpdate)
return