Why Nostr? What is Njump?
2024-03-25 03:10:47

Mo :ferris: :tux: on Nostr: #RustLang lint idea and performance tip 🚀 Warn about a repeated call of ...

#RustLang lint idea and performance tip 🚀

Warn about a repeated call of `Path::join` ⚠️

This allocates a new `PathBuf` each time. Then `Path::join` is called on the new `PathBuf` because of the `Deref` implementation.

Instead, you should use extend like in the screenshot (preferably with a capacity hint).

You can also use `.collect::<PathBuf>()` on an iterator instead:
https://doc.rust-lang.org/stable/std/path/struct.PathBuf.html#impl-FromIterator%3CP%3E-for-PathBuf



Author Public Key
npub1j7fc87rk03whjh72mphc9hrm8zecfsdywdcscsesznwzcrasudvs75mapy