Skip to content

fix: searchInMethods and searchInClasses - #58

Merged
teble merged 2 commits into
LuckyPray:masterfrom
tpnet:master
Aug 20, 2026
Merged

teble merged 2 commits into
LuckyPray:masterfrom
tpnet:master

Conversation

@tpnet

@tpnet tpnet commented Aug 18, 2026

Copy link
Copy Markdown

No description provided.

@teble

teble commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

batchFind API 中 关于 searchIn* 的逻辑确实有误,EndWith 在特殊情况下的匹配也确实存在 bug,应该在满足 pattern.size() <= opcodes.size() 后直接比较尾部,例如:
std::equal(pattern.begin(), pattern.end(), opcodes.end() - pattern.size());

不过该 PR 引入了 opcode 允许使用 -1 作为通配的逻辑,并将原有的 opcode Contain 的 KMP 匹配替换成朴素实现,导致在极端情况下匹配复杂度会从 O(n+m) 退化成 O(n*m)。

我认为本 PR 应该保持为纯粹的 bugfix,只修复已有行为:

  • 修正 searchIn* 的判断逻辑
  • 修复 EndWith 的尾部匹配

opcode 通配符可以考虑支持,但是应拆到独立 PR 中讨论 API 及实现

EndWith was anchored to the first occurrence found by kmp::FindIndex,
so a pattern that also appears earlier in the sequence failed to match
the tail. Compare the tail directly instead.
@tpnet

tpnet commented Aug 20, 2026

Copy link
Copy Markdown
Author

已按建议调整

@teble
teble merged commit 47f7324 into LuckyPray:master Aug 20, 2026
4 checks passed
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.

2 participants