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.
This first compares the
Repr
before falling back to actually comparing the rawas_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.