From 241cfae9a193850a8ce5b6e96c97bc1d70f80fc6 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:28:34 +0700 Subject: [PATCH] Optimize Preferences.get() --- better-xcloud.user.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/better-xcloud.user.js b/better-xcloud.user.js index ab40c64..37c3921 100644 --- a/better-xcloud.user.js +++ b/better-xcloud.user.js @@ -6534,7 +6534,7 @@ class Preferences { } if (settingId in savedPrefs) { - this.#prefs[settingId] = savedPrefs[settingId]; + this.#prefs[settingId] = this.#validateValue(settingId, savedPrefs[settingId]); } else { this.#prefs[settingId] = setting.default; } @@ -6588,10 +6588,11 @@ class Preferences { return Preferences.SETTINGS[key].default; } - let value = this.#prefs[key]; - value = this.#validateValue(key, value); + if (!(key in this.#prefs)) { + this.#prefs[key] = this.#validateValue(key, null); + } - return value; + return this.#prefs[key]; } set(key, value) { @@ -6921,7 +6922,7 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) { [ 'disableGamepadDisconnectedScreen', - getPref(Preferences.MKB_ENABLED) && 'mkbMouseAndKeyboardEnabled', + ENABLE_NATIVE_MKB_BETA && getPref(Preferences.MKB_ENABLED) && 'mkbMouseAndKeyboardEnabled', ], ];