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 + "'");
return function(img) { el = $.el('a', {
return $.el('a', {
href: href(img),
target: '_blank', target: '_blank',
textContent: domain textContent: domain
}); });
return function(img) {
var a;
a = el.cloneNode(true);
a.href = href(img);
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}'"
(img) -> el = $.el 'a',
$.el 'a',
href: href img
target: '_blank' target: '_blank'
textContent: domain textContent: domain
(img) ->
a = el.cloneNode true
a.href = href img
a
node: (post) -> node: (post) ->
{img} = post {img} = post