File tree 4 files changed +7
-4
lines changed
.changelog/unreleased/improvements
ics04-channel/types/src/events
4 files changed +7
-4
lines changed Original file line number Diff line number Diff line change
1
+ - Reduce heap allocation by using ` str ` instead of ` String ` places we convert
2
+ domain event attributes to the ABCI event attributes
3
+ ([ \# 970] ( https://github.com/cosmos/ibc-rs/issues/970 ) )
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ impl From<HeaderAttribute> for abci::EventAttribute {
153
153
fn from ( attr : HeaderAttribute ) -> Self {
154
154
(
155
155
HEADER_ATTRIBUTE_KEY ,
156
- String :: from_utf8 ( hex:: encode ( attr. header ) )
156
+ str :: from_utf8 ( & hex:: encode ( attr. header ) )
157
157
. expect ( "Never fails because hexadecimal is valid UTF-8" ) ,
158
158
)
159
159
. into ( )
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ impl TryFrom<PacketDataAttribute> for Vec<abci::EventAttribute> {
59
59
. into( ) ,
60
60
(
61
61
PKT_DATA_HEX_ATTRIBUTE_KEY ,
62
- String :: from_utf8( hex:: encode( attr. packet_data) )
62
+ str :: from_utf8( & hex:: encode( attr. packet_data) )
63
63
. expect( "Never fails because hexadecimal is valid UTF8" ) ,
64
64
)
65
65
. into( ) ,
@@ -329,7 +329,7 @@ impl TryFrom<AcknowledgementAttribute> for Vec<abci::EventAttribute> {
329
329
. into( ) ,
330
330
(
331
331
PKT_ACK_HEX_ATTRIBUTE_KEY ,
332
- String :: from_utf8( hex:: encode( attr. acknowledgement) )
332
+ str :: from_utf8( & hex:: encode( attr. acknowledgement) )
333
333
. expect( "Never fails because hexadecimal is always valid UTF-8" ) ,
334
334
)
335
335
. into( ) ,
Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ pub use alloc::borrow::ToOwned;
4
4
pub use alloc:: boxed:: Box ;
5
5
pub use alloc:: string:: { String , ToString } ;
6
6
pub use alloc:: vec:: Vec ;
7
- pub use alloc:: { format, vec} ;
7
+ pub use alloc:: { format, str , vec} ;
8
8
pub use core:: prelude:: v1:: * ;
You can’t perform that action at this time.
0 commit comments