Skip to content

Commit 7ec8676

Browse files
committed
f - offset without for loop
1 parent b017b1c commit 7ec8676

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lightning/src/offers/invoice.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,11 +1240,10 @@ impl TryFrom<Vec<u8>> for UnsignedBolt12Invoice {
12401240

12411241
let tagged_hash = TaggedHash::from_valid_tlv_stream_bytes(SIGNATURE_TAG, &bytes);
12421242

1243-
let mut offset = 0;
1244-
for tlv_record in TlvStream::new(&bytes).range(0..INVOICE_TYPES.end) {
1245-
offset = tlv_record.end;
1246-
}
1247-
1243+
let offset = TlvStream::new(&bytes)
1244+
.range(0..INVOICE_TYPES.end)
1245+
.last()
1246+
.map_or(0, |last_record| last_record.end);
12481247
let experimental_bytes = bytes.split_off(offset);
12491248

12501249
Ok(UnsignedBolt12Invoice { bytes, experimental_bytes, contents, tagged_hash })

0 commit comments

Comments
 (0)