softTask optimizations.
Conflicts: LICENSE builds/appchan-x.user.js builds/crx/script.js
This commit is contained in:
parent
4f50fd300d
commit
71f4bbc4de
@ -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();
|
||||
},
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
},
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user