Skip to content

InitChannelCache 函数中存在未使用的变量 newChannelId2channel #2321

Open
Sagit-chu/one-api
#126

Description

@lDuang

例行检查
[//]: # (方框内删除已有的空格,填 x 号)

  • 我已确认目前没有类似 issue
  • 我已确认我已升级到最新版本
  • 我已完整查看过项目 README,尤其是常见问题部分
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

问题描述
在 model/cache.go 文件的 InitChannelCache 函数中,存在一个未使用的变量 newChannelId2channel。该变量被初始化为 map[int]*Channel 并通过遍历 channels 切片赋值,但后续代码中未对其进行任何引用,我认为是冗余代码。

复现步骤

  1. 打开项目文件 model/cache.go
  2. 定位到 InitChannelCache 函数
  3. 观察到 newChannelId2channel 变量被定义和赋值,搜索后发现,后续无任何引用

预期结果
我认为应该删除此变量,保持代码简洁,不影响原有功能。

相关截图
Image

Activity

  1. added a commit that references this issue on Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions