Fix and recomprehense the setInterval function

This commit is contained in:
Zixaphir 2013-12-16 20:07:27 -07:00
parent 7958371a24
commit 75b7804eda
3 changed files with 43 additions and 25 deletions

View File

@ -9010,15 +9010,19 @@
}
},
setInterval: function() {
var cur, i, j;
var cur, i, j, limit;
i = ThreadUpdater.interval;
j = (cur = ThreadUpdater.outdateCount < 10) ? cur : 10;
if (!d.hidden) {
j = j < 7 ? j : 7;
i = ThreadUpdater.interval + 1;
if (Conf['Optional Increase']) {
cur = ThreadUpdater.outdateCount || 1;
limit = d.hidden ? 7 : 10;
j = cur <= limit ? cur : limit;
cur = ((i * 0.1).floor() || 1) * j * j;
ThreadUpdater.seconds = cur > i ? cur <= 300 ? cur : 300 : i;
} else {
ThreadUpdater.seconds = i;
}
ThreadUpdater.seconds = Conf['Optional Increase'] ? (cur = [0, 5, 10, 15, 20, 30, 60, 90, 120, 240, 300][j] > i) ? cur : i : i;
ThreadUpdater.set('timer', ThreadUpdater.seconds++);
ThreadUpdater.set('timer', ThreadUpdater.seconds);
return ThreadUpdater.count(true);
},
intervalShortcut: function() {

View File

@ -8995,15 +8995,19 @@
}
},
setInterval: function() {
var cur, i, j;
var cur, i, j, limit;
i = ThreadUpdater.interval;
j = (cur = ThreadUpdater.outdateCount < 10) ? cur : 10;
if (!d.hidden) {
j = j < 7 ? j : 7;
i = ThreadUpdater.interval + 1;
if (Conf['Optional Increase']) {
cur = ThreadUpdater.outdateCount || 1;
limit = d.hidden ? 7 : 10;
j = cur <= limit ? cur : limit;
cur = ((i * 0.1).floor() || 1) * j * j;
ThreadUpdater.seconds = cur > i ? cur <= 300 ? cur : 300 : i;
} else {
ThreadUpdater.seconds = i;
}
ThreadUpdater.seconds = Conf['Optional Increase'] ? (cur = [0, 5, 10, 15, 20, 30, 60, 90, 120, 240, 300][j] > i) ? cur : i : i;
ThreadUpdater.set('timer', ThreadUpdater.seconds++);
ThreadUpdater.set('timer', ThreadUpdater.seconds);
return ThreadUpdater.count(true);
},
intervalShortcut: function() {

View File

@ -148,18 +148,28 @@ ThreadUpdater =
ThreadUpdater.cb.checkpost()
setInterval: ->
i = ThreadUpdater.interval
# Math.min/max is provably slow: http://jsperf.com/math-s-min-max-vs-homemade/5
j = if cur = ThreadUpdater.outdateCount < 10 then cur else 10
unless d.hidden
i = ThreadUpdater.interval + 1
if Conf['Optional Increase']
# Lower the max refresh rate limit on visible tabs.
j = if j < 7 then j else 7
ThreadUpdater.seconds =
if Conf['Optional Increase']
if cur = [0, 5, 10, 15, 20, 30, 60, 90, 120, 240, 300][j] > i then cur else i
else
i
ThreadUpdater.set 'timer', ThreadUpdater.seconds++
cur = ThreadUpdater.outdateCount or 1
limit = if d.hidden then 7 else 10
j = if cur <= limit then cur else limit
# 1 second to 100, 30 to 300.
cur = ((i * 0.1).floor() or 1) * j * j
ThreadUpdater.seconds =
if cur > i
if cur <= 300
cur
else
300
else
i
else
ThreadUpdater.seconds = i
ThreadUpdater.set 'timer', ThreadUpdater.seconds
ThreadUpdater.count true
intervalShortcut: ->