Skip to content

Commit 369ccf7

Browse files
committed
apparently custom setinterval/timeout functions makes the game like 40% slower
1 parent b24ea54 commit 369ccf7

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

game/js/Cfunction.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,4 @@
11
/* eslint-disable complexity */
2-
window.setInterval = function (delay, fn) {
3-
var start = Date.now();
4-
var data = {};
5-
data.id = requestAnimationFrame(loop);
6-
7-
return data;
8-
9-
function loop() {
10-
data.id = requestAnimationFrame(loop);
11-
12-
if (Date.now() - start >= delay) {
13-
fn();
14-
start = Date.now();
15-
}
16-
}
17-
};
18-
19-
window.clearInterval = function (data) {
20-
try {
21-
cancelAnimationFrame(data.id);
22-
} catch (e) {
23-
console.warn("clearInterval failed:", e);
24-
}
25-
};
26-
27-
window.setTimeout = function (fn, delay, ...args) {
28-
var start = Date.now();
29-
var data = Object.create(null);
30-
data.id = requestAnimationFrame(loop);
31-
32-
return data;
33-
34-
function loop() {
35-
Date.now() - start >= delay ? fn(...args) : (data.id = requestAnimationFrame(loop));
36-
}
37-
};
38-
39-
window.clearTimeout = function (data) {
40-
if (data && typeof data === "object" && data.id !== undefined) {
41-
try {
42-
cancelAnimationFrame(data.id);
43-
} catch (e) {
44-
console.warn("clearTimeout failed:", e);
45-
}
46-
}
47-
};
48-
492
var $User = (function () {
503
const platform = navigator.platform;
514
const userAgent = navigator.userAgent;

0 commit comments

Comments
 (0)