rust-analyzer / smol_str

Apache License 2.0
424 stars 54 forks source link

Add `PartialEq` shortcut for `ptr_eq` strings #67

Closed Swatinem closed 7 months ago

Swatinem commented 8 months ago

This first compares the Repr before falling back to actually comparing the raw as_str itself. In some micro-benchmarks, this speeds up inline and heap string comparisons when equal by ~70%.

There is a tiny hit in the non-equal case however. It is also noteworthy that the assembly generated for Repr is horrible, and looks like its above the inlining threshold now.

Veykril commented 7 months ago

Thanks!