Skip to content

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