Fix Thread Stats slowdown; use querySelector once.

This commit is contained in:
Nicolas Stepien 2011-07-19 00:53:00 +02:00
parent 6e1de66b40
commit faaf8a8c00
3 changed files with 11 additions and 10 deletions

View File

@ -2275,6 +2275,8 @@
left: '0px' left: '0px'
}, html); }, html);
dialog.className = 'dialog'; dialog.className = 'dialog';
threadStats.postcountID = $('#postcount', dialog);
threadStats.imagecountID = $('#imagecount', dialog);
$.append(d.body, dialog); $.append(d.body, dialog);
return g.callbacks.push(threadStats.node); return g.callbacks.push(threadStats.node);
}, },
@ -2282,15 +2284,13 @@
if (root.className) { if (root.className) {
return; return;
} }
threadStats.posts++; threadStats.postcountID.textContent = ++threadStats.posts;
if ($('img[md5]', root)) { if ($('img[md5]', root)) {
threadStats.images++; threadStats.imagecountID.textContent = ++threadStats.images;
if (threadStats.images > 150) { if (threadStats.images > 150) {
$('#imagecount').className = 'error'; return threadStats.imagecountID.className = 'error';
} }
} }
$('#postcount').textContent = threadStats.posts;
return $('#imagecount').textContent = threadStats.images;
} }
}; };
unread = { unread = {

View File

@ -1,5 +1,6 @@
- mayhem: - mayhem:
- Fix Auto Watch Reply and prevent upload of too large files when auto posting - Fix Auto Watch Reply and prevent upload of too large files when auto posting
- Thread Stats performance fix, especially on long threads
2.15.1 2.15.1
- mayhem: - mayhem:

View File

@ -1746,17 +1746,17 @@ threadStats =
html = "<div class=move><span id=postcount>#{threadStats.posts}</span> / <span id=imagecount>#{threadStats.images}</span></div>" html = "<div class=move><span id=postcount>#{threadStats.posts}</span> / <span id=imagecount>#{threadStats.images}</span></div>"
dialog = ui.dialog 'stats', bottom: '0px', left: '0px', html dialog = ui.dialog 'stats', bottom: '0px', left: '0px', html
dialog.className = 'dialog' dialog.className = 'dialog'
threadStats.postcountID = $ '#postcount', dialog
threadStats.imagecountID = $ '#imagecount', dialog
$.append d.body, dialog $.append d.body, dialog
g.callbacks.push threadStats.node g.callbacks.push threadStats.node
node: (root) -> node: (root) ->
return if root.className return if root.className
threadStats.posts++ threadStats.postcountID.textContent = ++threadStats.posts
if $ 'img[md5]', root if $ 'img[md5]', root
threadStats.images++ threadStats.imagecountID.textContent = ++threadStats.images
if threadStats.images > 150 if threadStats.images > 150
$('#imagecount').className = 'error' threadStats.imagecountID.className = 'error'
$('#postcount').textContent = threadStats.posts
$('#imagecount').textContent = threadStats.images
unread = unread =
init: -> init: ->