perf: optimize NIP-21 URI parsing in PublicKey::parse#1308
Merged
yukibtc merged 1 commit intoMar 31, 2026
Conversation
Align NIP-21 parsing performance with standard bech32 parsing. Previously, NIP-21 URIs (which are essentially bech32 strings with a prefix) took ~104% longer to parse than raw bech32 keys. By streamlining the prefix handling, NIP-21 parsing time has been reduced by ~51%, bringing it within the expected margin of standard bech32 performance. Benchmarks: | Bench | Before (ns/iter) | After (ns/iter) | Δ | |-----------------------|------------------|-----------------|--------| | parse_bech32 | 591.20 | 592.77 | ~0% | | parse_nip21_uri | 1,225.93 | 598.44 | -51.2% | Signed-off-by: Awiteb <a@4rs.nl>
e36d346 to
5d9d97e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1308 +/- ##
==========================================
- Coverage 69.64% 69.62% -0.02%
==========================================
Files 188 188
Lines 31255 31251 -4
==========================================
- Hits 21769 21760 -9
- Misses 9486 9491 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
Author
|
This is the report using
|
yukibtc
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Align NIP-21 parsing performance with standard bech32 parsing. Previously, NIP-21 URIs (which are essentially bech32 strings with a prefix) took ~104% longer to parse than raw bech32 keys.
By streamlining the prefix handling, NIP-21 parsing time has been reduced by ~51%, bringing it within the expected margin of standard bech32 performance.
Benchmarks:
Checklist