Mo :ferris: :tux: on Nostr: #RustLang lint idea and performance tip 🚀 Warn about a repeated call of ...
Published at
2024-03-25 03:10:47Event JSON
{
"id": "189d84f5618e44756e0667e2f63011e767cc374ad99a0105f299c46060481968",
"pubkey": "979383f8767c5d795fcad86f82dc7b38b384c1a473710c433014dc2c0fb0e359",
"created_at": 1711336247,
"kind": 1,
"tags": [
[
"t",
"rustlang"
],
[
"proxy",
"https://fosstodon.org/users/mo8it/statuses/112154132343279644",
"activitypub"
]
],
"content": "#RustLang lint idea and performance tip 🚀\n\nWarn about a repeated call of `Path::join` ⚠️\n\nThis allocates a new `PathBuf` each time. Then `Path::join` is called on the new `PathBuf` because of the `Deref` implementation.\n\nInstead, you should use extend like in the screenshot (preferably with a capacity hint).\n\nYou can also use `.collect::\u003cPathBuf\u003e()` on an iterator instead:\nhttps://doc.rust-lang.org/stable/std/path/struct.PathBuf.html#impl-FromIterator%3CP%3E-for-PathBuf\n\nhttps://cdn.fosstodon.org/media_attachments/files/112/154/112/266/667/727/original/c66830e8709f3f86.png\n\nhttps://cdn.fosstodon.org/media_attachments/files/112/154/113/890/868/537/original/2fa4c8aad38a3ff6.png",
"sig": "43a35a9e918fe498e8185724aa1d143f440198460fd1549a809b27dfe3aef9b5d92210432c2b77ebeb8df948ebdc62ee8757d83b89f3dbc8946574b20c6eda6b"
}