Check whether vector value needs to be dropped in Vec#truncate by sugar700 · Pull Request #57949 · rust-lang/rust (original) (raw)
Primarily, this is nowhere near the only part of the standard library that could benefit from treatment like this.
Agreed. Even then, I don't think it's a bad idea to do that in places that can benefit from it, even if there is much more to do.
Practically the entire standard library is built on "unnecessary" abstractions that compile away and could be hand-coded much more efficiently at O0. I'm not really sure why we'd single out just one method to get fixed.
Mostly because users actually workaround around that one. See kmeisthax/rapidtar@92f4af2
Secondarily, this actually makes code at O0 somewhat worse in terms of codegen time. LLVM now has to emit this much more code (new branches) for all calls to this functions, and then LLVM has to emit code for all that.
I.e. having more tokens in a source code slows down compilation. This is technically true, although mostly meaningless.