diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 59622aa15..ea6e6b62c 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -11902,26 +11902,8 @@ var errors, func, i, len, node, queue, softTask; queue = []; - softTask = function() { - var args, func, task; - - task = queue.shift(); - func = task[0]; - args = Array.prototype.slice.call(task, 1); - func.apply(func, args); - if (!queue.length) { - return; - } - if ((queue.length % 7) === 0) { - return setTimeout(softTask, 0); - } else { - return softTask(); - } - }; - len = nodes.length; - i = 0; errors = null; - func = function(node, i) { + func = function(node) { var callback, err, _i, _len, _ref; _ref = klass.callbacks; @@ -11940,7 +11922,7 @@ }); } } - if (i === len) { + if (!queue.length) { if (errors) { Main.handleErrors(errors); } @@ -11949,9 +11931,25 @@ } } }; + softTask = function() { + var node; + + node = queue.shift(); + func(node); + if (!queue.length) { + return; + } + if (!(queue.length % 7)) { + return setTimeout(softTask, 0); + } else { + return softTask(); + } + }; + len = nodes.length; + i = 0; while (i < len) { - node = nodes[i]; - queue.push([func, node, ++i]); + node = nodes[i++]; + queue.push(node); } return softTask(); }, diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 2819c8819..a3c295add 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -20,7 +20,11 @@ // ==/UserScript== /* +<<<<<<< HEAD * appchan x - Version 2.4.1 - 2013-10-19 +======= +* appchan x - Version 2.4.1 - 2013-10-17 +>>>>>>> fefe8a2... softTask optimizations. * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/crx/script.js b/builds/crx/script.js index ece8bb52f..3e1dad4a6 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -11893,26 +11893,8 @@ var errors, func, i, len, node, queue, softTask; queue = []; - softTask = function() { - var args, func, task; - - task = queue.shift(); - func = task[0]; - args = Array.prototype.slice.call(task, 1); - func.apply(func, args); - if (!queue.length) { - return; - } - if ((queue.length % 7) === 0) { - return setTimeout(softTask, 0); - } else { - return softTask(); - } - }; - len = nodes.length; - i = 0; errors = null; - func = function(node, i) { + func = function(node) { var callback, err, _i, _len, _ref; _ref = klass.callbacks; @@ -11931,7 +11913,7 @@ }); } } - if (i === len) { + if (!queue.length) { if (errors) { Main.handleErrors(errors); } @@ -11940,9 +11922,25 @@ } } }; + softTask = function() { + var node; + + node = queue.shift(); + func(node); + if (!queue.length) { + return; + } + if (!(queue.length % 7)) { + return setTimeout(softTask, 0); + } else { + return softTask(); + } + }; + len = nodes.length; + i = 0; while (i < len) { - node = nodes[i]; - queue.push([func, node, ++i]); + node = nodes[i++]; + queue.push(node); } return softTask(); }, diff --git a/src/General/Main.coffee b/src/General/Main.coffee index e2ce90956..d5a847e4e 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -252,23 +252,9 @@ Main = callbackNodesDB: (klass, nodes, cb) -> queue = [] - softTask = -> - task = queue.shift() - func = task[0] - args = Array::slice.call task, 1 - func.apply func, args - return unless queue.length - if (queue.length % 7) is 0 - setTimeout softTask, 0 - else - softTask() - - # get the nodes' length only once - len = nodes.length - i = 0 errors = null - func = (node, i) -> + func = (node) -> for callback in klass.callbacks try callback.cb.call node @@ -278,13 +264,26 @@ Main = message: "\"#{callback.name}\" crashed on #{klass.name} No.#{node} (/#{node.board}/)." error: err # finish - if i is len + unless queue.length Main.handleErrors errors if errors cb() if cb + softTask = -> + node = queue.shift() + func node + return unless queue.length + unless queue.length % 7 + setTimeout softTask, 0 + else + softTask() + + # get the nodes' length only once + len = nodes.length + i = 0 + while i < len - node = nodes[i] - queue.push [func, node, ++i] + node = nodes[i++] + queue.push node softTask()