Slight performance improvements for sauces. Precreate and clone the node instead of creating it each call.

This commit is contained in:
Nicolas Stepien 2012-03-05 00:45:14 +01:00
parent 6f87b3ff14
commit 2cbac888d0
2 changed files with 15 additions and 10 deletions

View File

@ -2798,7 +2798,7 @@
return g.callbacks.push(this.node); return g.callbacks.push(this.node);
}, },
funk: function(link) { funk: function(link) {
var domain, href; var domain, el, href;
domain = link.match(/(\w+)\.\w+\//)[1]; domain = link.match(/(\w+)\.\w+\//)[1];
href = link.replace(/(\$\d)/g, function(parameter) { href = link.replace(/(\$\d)/g, function(parameter) {
switch (parameter) { switch (parameter) {
@ -2813,12 +2813,15 @@
} }
}); });
href = Function('img', "return '" + href + "'"); href = Function('img', "return '" + href + "'");
el = $.el('a', {
target: '_blank',
textContent: domain
});
return function(img) { return function(img) {
return $.el('a', { var a;
href: href(img), a = el.cloneNode(true);
target: '_blank', a.href = href(img);
textContent: domain return a;
});
}; };
}, },
node: function(post) { node: function(post) {

View File

@ -2324,11 +2324,13 @@ sauce =
when '$4' when '$4'
g.BOARD g.BOARD
href = Function 'img', "return '#{href}'" href = Function 'img', "return '#{href}'"
el = $.el 'a',
target: '_blank'
textContent: domain
(img) -> (img) ->
$.el 'a', a = el.cloneNode true
href: href img a.href = href img
target: '_blank' a
textContent: domain
node: (post) -> node: (post) ->
{img} = post {img} = post