Skip to main content

constant_time_contains_case_insensitive

Function constant_time_contains_case_insensitive 

Source
pub fn constant_time_contains_case_insensitive(
    haystack: &[u8],
    needle: &[u8],
) -> bool
Expand description

恒定时间 ASCII 大小写不敏感子串匹配(AGENT.md §4.9 时序安全)

constant_time_contains 同一安全语义: 遍历全部对齐位置、逐字节 XOR 累积差异、无数据相关分支、不提前退出, 执行时间仅取决于输入长度,与是否命中、命中位置无关。 比较前在寄存器内逐字节 ASCII 折叠为小写,零堆分配 (替代热路径 to_lowercase()/to_uppercase() 的每请求堆分配)。

§Arguments

  • haystack - 被搜索的字节串(任意大小写)
  • needle - 待匹配的模式串(任意大小写;空模式恒为命中)

§Returns

  • bool - 忽略 ASCII 大小写后,haystack 中是否包含 needle