perf: remove unnecessary useMemo wrapping simple boolean expressions

Replace useMemo calls that wrap trivial boolean checks with plain
const expressions. The memo overhead exceeds the cost of these
simple permission checks and mode comparisons.

Fixes #1052
This commit is contained in:
Matt Van Horn 2026-04-08 01:36:24 -07:00
parent 553843ab06
commit 90ed853a26
5 changed files with 18 additions and 49 deletions

View file

@ -121,9 +121,8 @@ export function ModelSelector({
return llmUserConfigs?.find((c) => c.id === agentLlmId) ?? null;
}, [preferences, llmGlobalConfigs, llmUserConfigs]);
const isLLMAutoMode = useMemo(() => {
return currentLLMConfig && "is_auto_mode" in currentLLMConfig && currentLLMConfig.is_auto_mode;
}, [currentLLMConfig]);
const isLLMAutoMode =
currentLLMConfig && "is_auto_mode" in currentLLMConfig && currentLLMConfig.is_auto_mode;
// ─── Image current config ───
const currentImageConfig = useMemo(() => {
@ -135,11 +134,8 @@ export function ModelSelector({
return imageUserConfigs?.find((c) => c.id === id) ?? null;
}, [preferences, imageGlobalConfigs, imageUserConfigs]);
const isImageAutoMode = useMemo(() => {
return (
currentImageConfig && "is_auto_mode" in currentImageConfig && currentImageConfig.is_auto_mode
);
}, [currentImageConfig]);
const isImageAutoMode =
currentImageConfig && "is_auto_mode" in currentImageConfig && currentImageConfig.is_auto_mode;
// ─── Vision current config ───
const currentVisionConfig = useMemo(() => {