From 12d6fbd9c8a785682b0e8e8e1484344558a970de Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 2 Dec 2023 11:10:36 +0700 Subject: [PATCH] Check patches one by one to improve performance --- better-xcloud.user.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/better-xcloud.user.js b/better-xcloud.user.js index 639e3c7..0069d8c 100644 --- a/better-xcloud.user.js +++ b/better-xcloud.user.js @@ -4403,6 +4403,7 @@ class Patcher { static length() { return Object.keys(Patcher.#PATCHES).length }; static patch(item) { + let patchName; for (let id in item[1]) { if (Patcher.length() <= 0) { return; @@ -4411,16 +4412,18 @@ class Patcher { const func = item[1][id]; const funcStr = func.toString(); - let patchedFuncStr; - for (const patchName in Patcher.#PATCHES) { - patchedFuncStr = Patcher.#PATCHES[patchName].call(null, funcStr); - if (patchedFuncStr) { - item[1][id] = eval(patchedFuncStr); - delete Patcher.#PATCHES[patchName]; + // Only check the first patch + if (!patchName) { + patchName = Object.keys(Patcher.#PATCHES)[0]; + } - console.log(`[Better xCloud] Applied "${patchName}" patch`); - break; - } + const patchedFuncStr = Patcher.#PATCHES[patchName].call(null, funcStr); + if (patchedFuncStr) { + console.log(`[Better xCloud] Applied "${patchName}" patch`); + + item[1][id] = eval(patchedFuncStr); + delete Patcher.#PATCHES[patchName]; + patchName = null; } } }