keep-starknet-strange / joyboy

Decentralized social built with Nostr and powered by Starknet account abstraction.
https://joyboy.community
MIT License
62 stars 41 forks source link

feat: Optimize bech32 Encoding Performance #119

Closed juandiegocv27 closed 1 month ago

juandiegocv27 commented 1 month ago

Optimized the Bech32 encoding implementation for better performance and efficiency:

-Constant ALPHABET: Defined ALPHABET as a global constant for Bech32 characters. -Memory Preallocation: Preallocated memory for the encoded result in the encode function. -Use of while Loops: Used while loops for controlled iteration in compliance with Cairo's constraints. -Optimized byte-to-5-bit Conversion: Improved convert_bytes_to_5bit_chunks function with more efficient bitwise -operations. -Optimized Checksum Calculation: Enhanced the checksum function for better array handling and efficiency.

These changes address the performance improvements requested in issue #74.

Before and After: -Function convert_bytes_to_5bit_chunks After: image Before: image

Function encode After: image Before: image

Any suggestions are welcome, and I'm happy to make any changes you need. @maciejka @mubarak23

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
joyboy ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2024 2:12am
joyboy-webapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2024 2:12am