Skip to content

fix(lyricParser): 修复了一些 alignLyricLines 的小问题#996

Merged
apoint123 merged 4 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/ral
Mar 15, 2026
Merged

fix(lyricParser): 修复了一些 alignLyricLines 的小问题#996
apoint123 merged 4 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/ral

Conversation

@MoYingJi
Copy link
Copy Markdown
Collaborator

详情可查看每个提交

Copilot AI review requested due to automatic review settings March 13, 2026 17:40
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求主要针对 lyricParser.ts 文件中的 alignLyricLines 函数进行了一系列修复和改进。这些更改旨在提升函数性能、增强数据处理的健壮性、确保类型安全,并避免在处理歌词数据时产生意外的副作用。通过引入新的参数和细化逻辑,该函数现在能更高效、更可靠地对歌词进行对齐。

Highlights

  • 性能优化: 为 alignLyricLines 函数新增了 assumeSorted 参数,允许在输入歌词已排序时跳过排序步骤,从而提升性能。
  • 类型安全与不变性: 将 alignLyricLines 函数的 lyrics 参数类型更新为 Readonly<LyricLine[]>,并明确返回值为新副本,增强了类型安全和数据不变性。
  • 健壮性增强: 在 isTimeMatch 辅助函数中增加了对 timeDiffendTimeDiffisFinite 检查,以处理潜在的非有限数值,提高了函数的健壮性。
  • 避免副作用: 当 endTime 参数设置为 "set" 且 base.words 存在时,对 base.words 进行了深拷贝,以防止在修改 baseLine.words 时意外修改原始输入数据。
Changelog
  • src/utils/lyric/lyricParser.ts
    • alignLyricLines 函数添加了 assumeSorted 参数,用于控制是否跳过歌词排序。
    • 更新了 alignLyricLines 函数的 lyrics 参数类型为 Readonly<LyricLine[]>,并明确返回新副本。
    • isTimeMatch 函数中增加了 isFinite 检查,以确保时间差值为有限数。
    • alignLyricLines 函数中,当 endTime 为 "set" 时,对 base.words 进行了深拷贝,以避免修改原始数据。
Activity
  • MoYingJi 创建了此拉取请求,旨在修复 alignLyricLines 函数中的一些小问题。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The alignLyricLines function in src/utils/lyric/lyricParser.ts has been updated to accept Readonly<LyricLine[]> as input, enhancing immutability. A new assumeSorted option was added to optimize performance by conditionally skipping the sorting step. Additionally, isFinite checks were introduced for timeDiff and endTimeDiff within the isTimeMatch helper to improve robustness against invalid time values, and a deep copy of base.words is now performed when endTime is 'set' to prevent unintended modifications of the original data.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

本 PR 聚焦于 alignLyricLines 的健壮性与可维护性:在对齐翻译/音译行时,补强异常时间值处理、避免意外修改入参,并提供可选的性能优化开关。

Changes:

  • alignLyricLines 入参改为 Readonly<LyricLine[]>,并在注释中明确返回新副本语义
  • 新增 assumeSorted 选项:可跳过排序以减少开销
  • 对时间差计算增加有限值校验,并在 endTime === "set" 时对 words 做深拷贝以避免副作用

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/utils/lyric/lyricParser.ts Outdated
fix(lyricParser): 使用 cloneDeep 代替手动展开
@apoint123 apoint123 merged commit 74b2569 into SPlayer-Dev:dev Mar 15, 2026
@MoYingJi MoYingJi deleted the pr/ral branch March 15, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants