Closed
Description
In a lot of rust code, I see "".to_string()
being used as the default method of creating a new string. This would normally be fine, but it's actually noticeably slower than String::new()
because it goes through the formatting infrastructure.
It'd be nice if this pattern could be special-cased in String::to_string
's implementation, or the optimizer made to do this transformation better.