Minor #3270 Followups#3349
Merged
TheBlueMatt merged 5 commits intolightningdevkit:mainfrom Oct 11, 2024
Merged
Conversation
In aa2f6b4 we refactored `lightning-invoice` de/serialization to use the new version of `bech32`, also reducing some trivial unnecessary allocations when we did so. Here we drop a few additional allocations which came up in review.
In aa2f6b4 we refactored `lightning-invoice` de/serialization to use the new version of `bech32`, but ended up adding one unnecessary allocation in our offers logic, which we drop here.
...in `debug_assertions`.
In aa2f6b4 we refactored `lightning-invoice` de/serialization to use the new version of `bech32`, but in order to keep the public API the same we introduced one allocation we could have skipped. Instead, here, we replace the public `Utf8Error` with `FromUtf8Error` which contains the original data which failed conversion, removing an allocation in the process.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3349 +/- ##
==========================================
- Coverage 89.62% 89.59% -0.04%
==========================================
Files 127 127
Lines 103517 103519 +2
Branches 103517 103519 +2
==========================================
- Hits 92780 92750 -30
- Misses 8041 8062 +21
- Partials 2696 2707 +11 ☔ View full report in Codecov by Sentry. |
When we serialize from a byte array to bech32 in `lightning-invoice`, we can either copy the array itself into the iterator or hold a reference to the array and iterate through that. In aa2f6b4 we opted to copy the array into the iterator, which is fine for the current array sizes we're working with, but does result in additional memory on the stack if, in the future, we end up writing large arrays. Instead, here, we switch to using the slice serialization code when writing arrays, (very marginally) reducing code size and reducing stack usage.
093f9fb to
5c1440a
Compare
arik-so
approved these changes
Oct 10, 2024
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.
No description provided.