Almost twice faster comment text reading for filters.

This commit is contained in:
Nicolas Stepien 2012-02-22 00:55:16 +01:00
parent 5db4f7e882
commit 5bd1d3ebb5
2 changed files with 25 additions and 4 deletions

View File

@ -631,9 +631,20 @@
return sub.textContent;
},
comment: function(root) {
return ($.el('a', {
innerHTML: root.lastChild.innerHTML.replace(/<br>/g, '\n')
})).textContent;
var i, len, node, nodes, text;
text = [];
nodes = d.evaluate('.//node()', root.lastChild, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
i = 0;
len = nodes.snapshotLength;
while (i < len) {
node = nodes.snapshotItem(i++);
if (node instanceof Text) {
text.push(node.data);
} else if (node instanceof HTMLBRElement) {
text.push('\n');
}
}
return text.join('');
},
filename: function(root) {
var file;

View File

@ -543,7 +543,17 @@ filter =
sub = if isOP then $ '.filetitle', root else $ '.replytitle', root
sub.textContent
comment: (root) ->
($.el 'a', innerHTML: root.lastChild.innerHTML.replace /<br>/g, '\n').textContent
text = []
nodes = d.evaluate './/node()', root.lastChild, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null
i = 0
len = nodes.snapshotLength
while i < len
node = nodes.snapshotItem i++
if node instanceof Text
text.push node.data
else if node instanceof HTMLBRElement
text.push '\n'
text.join ''
filename: (root) ->
if file = $ '.filesize > span', root
return file.title