Skip to content

Conversation

@cgwalters
Copy link

In https://github.com/ostreedev/ostree-rs-ext/ we are performing
hex encoding in loops and recursively, and it could be helpful
for performance to support re-using a buffer instead of allocating
a new String on the heap.

Currently we are using encode_to_slice, but then we need to
use e.g. std::str::from_utf8 which unnecessarily performs UTF-8
validation and is also hence fallible even though it doesn't need to be.

@cgwalters
Copy link
Author

Another alternative is to just make BytesToHexChars public.

@cgwalters cgwalters force-pushed the encode-to branch 2 times, most recently from d6d0122 to 8df0405 Compare December 17, 2021 19:08
@cgwalters
Copy link
Author

OK this is also much cleaner using String::extend and even better will honor the size hint.

To fix CI for git main/master.
In https://github.com/ostreedev/ostree-rs-ext/ we are performing
hex encoding in loops and recursively, and it could be helpful
for performance to support re-using a buffer instead of allocating
a new `String` on the heap.

Currently we are using `encode_to_slice`, but then we need to
use e.g. `std::str::from_utf8` which unnecessarily performs UTF-8
validation and is also hence fallible even though it doesn't need to be.
@cgwalters
Copy link
Author

I rolled in #67 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant