From 2cbac888d0eb1dbb5731d26901ff78603a2c7c41 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 5 Mar 2012 00:45:14 +0100 Subject: [PATCH] Slight performance improvements for sauces. Precreate and clone the node instead of creating it each call. --- 4chan_x.user.js | 15 +++++++++------ script.coffee | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bd568af1a..ceaab2e19 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2798,7 +2798,7 @@ return g.callbacks.push(this.node); }, funk: function(link) { - var domain, href; + var domain, el, href; domain = link.match(/(\w+)\.\w+\//)[1]; href = link.replace(/(\$\d)/g, function(parameter) { switch (parameter) { @@ -2813,12 +2813,15 @@ } }); href = Function('img', "return '" + href + "'"); + el = $.el('a', { + target: '_blank', + textContent: domain + }); return function(img) { - return $.el('a', { - href: href(img), - target: '_blank', - textContent: domain - }); + var a; + a = el.cloneNode(true); + a.href = href(img); + return a; }; }, node: function(post) { diff --git a/script.coffee b/script.coffee index f7748994f..3befc4ca3 100644 --- a/script.coffee +++ b/script.coffee @@ -2324,11 +2324,13 @@ sauce = when '$4' g.BOARD href = Function 'img', "return '#{href}'" + el = $.el 'a', + target: '_blank' + textContent: domain (img) -> - $.el 'a', - href: href img - target: '_blank' - textContent: domain + a = el.cloneNode true + a.href = href img + a node: (post) -> {img} = post