Another Main.preParser performance optimization.

This commit is contained in:
Nicolas Stepien 2012-03-06 23:59:39 +01:00
parent 7ab4487020
commit 19d0617f4c
2 changed files with 19 additions and 16 deletions

View File

@ -3986,21 +3986,22 @@
} }
}, },
preParse: function(node) { preParse: function(node) {
var klass; var klass, post;
klass = node.className; klass = node.className;
return { post = {
root: node, root: node,
el: klass === 'op' ? node : node.firstChild.firstChild.lastChild, el: klass === 'op' ? node : node.firstChild.firstChild.lastChild,
"class": klass, "class": klass,
id: $('input', node).name, id: node.getElementsByTagName('input')[0].name,
threadId: g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id, threadId: g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id,
isOP: klass === 'op', isOP: klass === 'op',
isInlined: /\binline\b/.test(klass), isInlined: /\binline\b/.test(klass),
filesize: $('.filesize', node), filesize: node.getElementsByClassName('filesize')[0] || false,
img: $('img[md5]', node),
quotes: node.getElementsByClassName('quotelink'), quotes: node.getElementsByClassName('quotelink'),
backlinks: node.getElementsByClassName('backlink') backlinks: node.getElementsByClassName('backlink')
}; };
post.img = post.filesize ? node.getElementsByTagName('img')[0] : false;
return post;
}, },
node: function(nodes, notify) { node: function(nodes, notify) {
var callback, node, _i, _j, _len, _len2, _ref; var callback, node, _i, _j, _len, _len2, _ref;

View File

@ -3319,17 +3319,19 @@ Main =
preParse: (node) -> preParse: (node) ->
klass = node.className klass = node.className
root: node post =
el: if klass is 'op' then node else node.firstChild.firstChild.lastChild root: node
class: klass el: if klass is 'op' then node else node.firstChild.firstChild.lastChild
id: $('input', node).name class: klass
threadId: g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id id: node.getElementsByTagName('input')[0].name
isOP: klass is 'op' threadId: g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id
isInlined: /\binline\b/.test klass isOP: klass is 'op'
filesize: $ '.filesize', node isInlined: /\binline\b/.test klass
img: $ 'img[md5]', node filesize: node.getElementsByClassName('filesize')[0] or false
quotes: node.getElementsByClassName 'quotelink' quotes: node.getElementsByClassName 'quotelink'
backlinks: node.getElementsByClassName 'backlink' backlinks: node.getElementsByClassName 'backlink'
post.img = if post.filesize then node.getElementsByTagName('img')[0] else false
post
node: (nodes, notify) -> node: (nodes, notify) ->
for callback in g.callbacks for callback in g.callbacks
try try