diff --git a/App/lib/core/Gen/StructGenMixin.vp b/App/lib/core/Gen/StructGenMixin.vp index 349d457..32eb114 100644 --- a/App/lib/core/Gen/StructGenMixin.vp +++ b/App/lib/core/Gen/StructGenMixin.vp @@ -893,9 +893,11 @@ class StructGenMixin: for i in range(start, self.StructCount): entry: GenTypes.StructEntry | t.CPtr = self._get_struct_entry(i) if entry is not None and entry.Name is not None: - if string.strcmp(entry.Name, name) == 0: + # 快速路径:strcmp 判等蕴含首字符相等,首字符不同者跳过 strcmp。 + if entry.Name[0] == name[0] and string.strcmp(entry.Name, name) == 0: if entry.ModuleSha1 is not None: - if string.strcmp(entry.ModuleSha1, sha1) == 0: + # 同上:sha1 判等蕴含首字符相等,先比首字符再 strcmp。 + if entry.ModuleSha1[0] == sha1[0] and string.strcmp(entry.ModuleSha1, sha1) == 0: return entry # SHA1 查找失败:不回退到 find_struct(会返回跨模块同名错误 entry) # 返回 None 让调用方创建新类型,避免 Phase B 用错误类型短路 diff --git a/App/lib/core/Gen/Type/TypeGenCType.vp b/App/lib/core/Gen/Type/TypeGenCType.vp index 9130d46..96b7469 100644 --- a/App/lib/core/Gen/Type/TypeGenCType.vp +++ b/App/lib/core/Gen/Type/TypeGenCType.vp @@ -148,7 +148,9 @@ class TypeGenCType(TypeGenBase.TypeGenBase): nm: str = self.CTypedefNames.get(i) if nm is None: continue - if string.strlen(nm) != want: + # 快速路径:命中要求 nm[0]==text[start](逐字节比较的 k=0 项), + # 首字节不同者无需 strlen 即可判定不命中(不影响任何原命中项)。 + if nm[0] != text[start] or string.strlen(nm) != want: continue hit: int = 1 k: sizet = 0