perf(llvmlite): _is_type_defined_in_module 同名判定先比首字符

已定义类型名链表的逐节点 strcmp 前加首字符必要条件短路(首字符不等即判不等),匹配结果逐字节不变,跳过绝大多数无谓比较(该点实测约 2500 万次)。
This commit is contained in:
TermiNexus committed 2026-09-14 04:09:16 +08:00
1 parent 215a1ca36a
commit c4c6eafd70
1 file changed
+2 -1
+2 -1
View File
@@ -182,7 +182,8 @@ class LLVMModule:
if cur.Ty is not None:
existing_name: str = get_struct_name(cur.Ty)
if existing_name is not None:
if string.strcmp(existing_name, name) == 0:
# 快速路径:strcmp 判等蕴含首字符相等,首字符不同者跳过 strcmp。
if existing_name[0] == name[0] and string.strcmp(existing_name, name) == 0:
return 1
cur = cur.Next
return 0