perf(methods): 通过移除不必要的 self 参数优化方法签名

在包括 chat、plugin_system、schedule 和 mais4u 在内的多个模块中,消除冗余的实例引用。此次改动将无需访问实例状态的实用函数转换为静态方法,从而提升了内存效率,并使方法依赖关系更加清晰。
This commit is contained in:
雅诺狐
2025-09-20 10:55:06 +08:00
committed by Windpicker-owo
parent aba4f1a947
commit 93542cadef
111 changed files with 705 additions and 465 deletions

View File

@@ -40,7 +40,8 @@ class ChatFrequencyAnalyzer:
self._analysis_cache: dict[str, tuple[float, list[tuple[time, time]]]] = {}
self._cache_ttl_seconds = 60 * 30 # 缓存30分钟
def _find_peak_windows(self, timestamps: List[float]) -> List[Tuple[datetime, datetime]]:
@staticmethod
def _find_peak_windows(timestamps: List[float]) -> List[Tuple[datetime, datetime]]:
"""
使用滑动窗口算法来识别时间戳列表中的高峰时段。

View File

@@ -21,7 +21,8 @@ class ChatFrequencyTracker:
def __init__(self):
self._timestamps: Dict[str, List[float]] = self._load_timestamps()
def _load_timestamps(self) -> Dict[str, List[float]]:
@staticmethod
def _load_timestamps() -> Dict[str, List[float]]:
"""从本地文件加载时间戳数据。"""
if not TRACKER_FILE.exists():
return {}