Skip to content

Abnormal-AT-segment-identification fixing#17

Merged
TaranDahl merged 3 commits into
Phobos-developers:masterfrom
WhiteFeather127:Abnormal-AT-segment-identification
Jun 12, 2026
Merged

Abnormal-AT-segment-identification fixing#17
TaranDahl merged 3 commits into
Phobos-developers:masterfrom
WhiteFeather127:Abnormal-AT-segment-identification

Conversation

@WhiteFeather127

Copy link
Copy Markdown
Contributor

fix #7

@TaranDahl

Copy link
Copy Markdown
Collaborator

_find_full_name_mentions 对每个 text segment 都会遍历全部缓存成员做 re.finditer。如果群组成员达到上千人,每条含 @ 的文本都会产生 O(n) 的正则扫描。对于高频的 QQ/Discord 消息转发场景可能有性能影响。
_find_full_name_mentions iterates through all cached members and runs re.finditer for every text segment. If a group has thousands of members, every message containing an @ triggers an O(n) regular expression scan. This may cause performance issues in high-frequency QQ/Discord message forwarding scenarios.

WhiteFeather127 added a commit to WhiteFeather127/QQ-DC-Bridge that referenced this pull request Jun 12, 2026
…apsulation, test coverage, parsing, retry limit
@WhiteFeather127

Copy link
Copy Markdown
Contributor Author

已修复,详见 commit e5386ec

优化了 _find_full_name_mentions 的性能问题:

  • 将逐成员 O(n) 正则扫描改为单个组合交替正则 O(1)
  • 使用 casefold() 做大小写不敏感的 display name 查找
  • 长名字优先匹配,避免短前缀误抢

Fixed in e5386ec.

Optimized _find_full_name_mentions performance:

  • Changed from per-member O(n) regex scans to a single combined alternation regex (O(1))
  • Uses casefold() for case-insensitive display name lookup
  • Longer names match first to prevent short-prefix false matches

@TaranDahl TaranDahl merged commit 64ca024 into Phobos-developers:master Jun 12, 2026
TaranDahl pushed a commit that referenced this pull request Jun 12, 2026
* binding-and-user-name-mapping

* fix PR #17 review issues: race condition, _cache encapsulation, test coverage, parsing, retry limit

* Disable QQ→Discord bind-by-nickname feature

Comment out the _parse_bind_target path that allowed QQ users to bind
to a Discord user by display name. The original code is preserved as
comments for reference.

PR review (TaranDahl): this feature is unnecessary; removing it also
eliminates the related name-matching issue (#4 in PR #16 review).

---------

Co-authored-by: WhiteFeather127 <whitefeather127@users.noreply.github.com>
@WhiteFeather127 WhiteFeather127 deleted the Abnormal-AT-segment-identification branch June 12, 2026 13:34
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.

Abnormal AT segment identification

2 participants