diff --git a/LICENSE b/LICENSE index ef1b94605..d360a8692 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* appchan x - Version 2.4.1 - 2013-10-16 +* appchan x - Version 2.4.1 - 2013-10-17 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 6c7c4a478..3a938d385 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -20,7 +20,7 @@ // ==/UserScript== /* -* appchan x - Version 2.4.1 - 2013-10-16 +* appchan x - Version 2.4.1 - 2013-10-17 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -15953,26 +15953,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; @@ -15991,7 +15973,7 @@ }); } } - if (i === len) { + if (!queue.length) { if (errors) { Main.handleErrors(errors); } @@ -16000,9 +15982,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/crx/script.js b/builds/crx/script.js index 7b862ed52..677dfe550 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* appchan x - Version 2.4.1 - 2013-10-16 +* appchan x - Version 2.4.1 - 2013-10-17 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -15941,26 +15941,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; @@ -15979,7 +15961,7 @@ }); } } - if (i === len) { + if (!queue.length) { if (errors) { Main.handleErrors(errors); } @@ -15988,9 +15970,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 050445ce9..e898542a5 100644 --- 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 @@ -279,13 +265,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()