uuid-rs / uuid

Generate and parse UUIDs.
https://www.crates.io/crates/uuid
Other
1k stars 192 forks source link

feat: avoid copying in TryFrom<Vec<u8>> #734

Closed pjenvey closed 7 months ago

pjenvey commented 9 months ago

Closes #733

KodrAus commented 9 months ago

Hi @pjenvey :wave:

For what it's worth it looks like these generate roughly equivalent code, but the existing implementation is slightly better: https://godbolt.org/z/138rGesMz

We end up creating a copy of the bytes anyway since uuid takes ownership of them. Did you observe some surprising behavior attempting to use these TryFrom conversions?

KodrAus commented 7 months ago

Thanks for the PR @pjenvey. I couldn't find a compelling reason to change this; they seemed to generate the same code, so will close this one to keep the source a bit simpler.

If you do notice any real-world impact here please feel free to re-open.