Skip to content

Commit 1e25979

Browse files
authored
Merge pull request #2714 from TheBlueMatt/2023-11-one-less-alloc
Avoid an unnecessary allocation in `TaggedHash`
2 parents 96e7d7a + 1aa5210 commit 1e25979

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lightning/src/offers/merkle.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tlv_stream!(SignatureTlvStream, SignatureTlvStreamRef, SIGNATURE_TYPES, {
3232
/// [BOLT 12]: https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md#signature-calculation
3333
#[derive(Clone, Debug, PartialEq)]
3434
pub struct TaggedHash {
35-
tag: String,
35+
tag: &'static str,
3636
merkle_root: sha256::Hash,
3737
digest: Message,
3838
}
@@ -41,12 +41,12 @@ impl TaggedHash {
4141
/// Creates a tagged hash with the given parameters.
4242
///
4343
/// Panics if `tlv_stream` is not a well-formed TLV stream containing at least one TLV record.
44-
pub(super) fn new(tag: &str, tlv_stream: &[u8]) -> Self {
44+
pub(super) fn new(tag: &'static str, tlv_stream: &[u8]) -> Self {
4545
let tag_hash = sha256::Hash::hash(tag.as_bytes());
4646
let merkle_root = root_hash(tlv_stream);
4747
let digest = Message::from_slice(&tagged_hash(tag_hash, merkle_root)).unwrap();
4848
Self {
49-
tag: tag.to_owned(),
49+
tag,
5050
merkle_root,
5151
digest,
5252
}

0 commit comments

Comments
 (0)