已开启
优化 themeChange 函数减少重复的 getTheme 调用 #1
f -创建于 2025年10月31日
优化 themeChange 函数减少重复的 getTheme 调用 #1
已开启
f -创建于 2025年10月31日
f -
f -
2025年10月31日

在 themeChange 函数中,getTheme() 被调用了 3 次来获取同一个主题对象,
这导致了不必要的数组 find() 操作。本次提交将 getTheme() 的结果缓存到
变量中并复用,以提升性能。

变更内容:

  • 将 getTheme(theme) 的结果缓存到 themeObj 变量中
  • 复用 themeObj 而不是多次调用 getTheme

此优化将 themeChange 函数中的函数调用从 3 次减少到 1 次,特别在
THEME_DATA 数组较大时能显著提升性能。

likedislike
合并受阻