]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Worlds smallest optimization
authorbenthecarman <benthecarman@live.com>
Thu, 8 Feb 2024 17:57:13 +0000 (17:57 +0000)
committerbenthecarman <benthecarman@live.com>
Thu, 8 Feb 2024 22:40:48 +0000 (22:40 +0000)
Preallocate for 8 items in the vec. I chose this value for

1. features
2. description
3. payment hash
4. expire time
5. min_final_cltv
6. payment secret
7. route hint
8. for the memes

lightning-invoice/src/lib.rs

index df0412bfc5d3e0d3876b177200527e01fd272678..610f739e57ad9d294610103edd36bbd5155d7109 100644 (file)
@@ -550,7 +550,7 @@ impl InvoiceBuilder<tb::False, tb::False, tb::False, tb::False, tb::False, tb::F
                        amount: None,
                        si_prefix: None,
                        timestamp: None,
-                       tagged_fields: Vec::new(),
+                       tagged_fields: Vec::with_capacity(8),
                        error: None,
 
                        phantom_d: core::marker::PhantomData,