From c4c6eafd708515e3f4e71affcbcd90214a28dc40 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Mon, 14 Sep 2026 04:09:16 +0800 Subject: [PATCH] =?UTF-8?q?perf(llvmlite):=20=5Fis=5Ftype=5Fdefined=5Fin?= =?UTF-8?q?=5Fmodule=20=E5=90=8C=E5=90=8D=E5=88=A4=E5=AE=9A=E5=85=88?= =?UTF-8?q?=E6=AF=94=E9=A6=96=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已定义类型名链表的逐节点 strcmp 前加首字符必要条件短路(首字符不等即判不等),匹配结果逐字节不变,跳过绝大多数无谓比较(该点实测约 2500 万次)。 --- llvmlite/__module.vp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvmlite/__module.vp b/llvmlite/__module.vp index ffc4ab0..943da30 100644 --- a/llvmlite/__module.vp +++ b/llvmlite/__module.vp @@ -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