pub fn same_symbol(left: &str, right: &str) -> boolExpand description
Whether two logical symbols name the same function. 两个逻辑符号是否指向同一个函数。
A live trace names a function by its bare symbol (button) while a MIR
candidate carries the fully qualified path (crate::ui::button), so the
match must also accept one side being a path suffix of the other. The suffix
has to start right after a :: boundary: a bare ends_with would treat
button as a suffix of fastbutton and silently discard a real candidate.
strip_suffix plus the boundary check preserves the original behaviour
without allocating the two format!("::{right}") strings on every
comparison — this runs in the nested merge loop, so those allocations were
paid per relation per candidate.
live trace 用裸符号(button)命名函数,而 MIR 候选取的是全限定路径
(crate::ui::button),因此匹配还须接受一方是另一方路径后缀。后缀必须紧接 ::
边界:裸的 ends_with 会把 button 当成 fastbutton 的后缀,静默丢掉一个真实候选。
strip_suffix 加边界检查在保持原行为的同时,不再每次比较都分配两个
format!("::{right}") 字符串——这段代码跑在归并的嵌套循环里,这些分配是按“每条关系
× 每个候选”付出的。
Pinned by same_symbol_requires_a_path_boundary_before_the_suffix.
由 same_symbol_requires_a_path_boundary_before_the_suffix 钉住。