Open yhx-12243 opened 3 months ago
It seems that the test needs to be changed, because it's probably that the compiler optimized out the whole test and did not allocate memory at all.
See https://rust.godbolt.org/z/qc349PrGv for a shorter analogue.
May be we should wrap this test in a something like core::hint::black_box
, or maybe do other things to make sure the compiler will not optimize out the "unused" allocation of long string.
fn as_bytes
inimpl CompactString
, there is an redundant slicing (with aself.len()
call) which is unnecessary after the update c95edd5.is_heap
can be replaced with directly returningfalse
to reduce some code generation.