Skip to content

Use unsafe APIs to optimize HexDisplay::to_hex_from #1848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Unparalleled-Calvin
Copy link

Hi there! This PR uses unsafe APIs including ptr::write and String::from_utf8_unchecked to boost performance of nom::HexDisplay::to_hex_from. Issue#1847 explains its safety and effectiveness.

The test and benchmark results demonstrate a 30% performance improvement for 36-byte data payloads while maintaining identical functionality to the existing implementation.

Btw, I am happy to provide the test and benchmark code if they are needed.

@Unparalleled-Calvin Unparalleled-Calvin changed the title use unsafe APIs to optimize HexDisplayDisplayto_hex_from Use unsafe APIs to optimize HexDisplayDisplayto_hex_from Apr 16, 2025
@Unparalleled-Calvin Unparalleled-Calvin changed the title Use unsafe APIs to optimize HexDisplayDisplayto_hex_from Use unsafe APIs to optimize HexDisplay::to_hex_from Apr 16, 2025
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