@@ -149,19 +149,24 @@ where
149
149
where
150
150
T : scale:: Encode ,
151
151
{
152
+ fn inner < E : Environment > ( encoded : & mut [ u8 ] ) -> <E as Environment >:: Hash {
153
+ let len_encoded = encoded. len ( ) ;
154
+ let mut result = <E as Environment >:: Hash :: clear ( ) ;
155
+ let len_result = result. as_ref ( ) . len ( ) ;
156
+ if len_encoded <= len_result {
157
+ result. as_mut ( ) [ ..len_encoded] . copy_from_slice ( encoded) ;
158
+ } else {
159
+ let mut hash_output = <Blake2x256 as HashOutput >:: Type :: default ( ) ;
160
+ <Blake2x256 as CryptoHash >:: hash ( encoded, & mut hash_output) ;
161
+ let copy_len = core:: cmp:: min ( hash_output. len ( ) , len_result) ;
162
+ result. as_mut ( ) [ 0 ..copy_len] . copy_from_slice ( & hash_output[ 0 ..copy_len] ) ;
163
+ }
164
+ result
165
+ }
166
+
152
167
let mut split = self . scoped_buffer . split ( ) ;
153
168
let encoded = split. take_encoded ( topic_value) ;
154
- let len_encoded = encoded. len ( ) ;
155
- let mut result = <E as Environment >:: Hash :: clear ( ) ;
156
- let len_result = result. as_ref ( ) . len ( ) ;
157
- if len_encoded <= len_result {
158
- result. as_mut ( ) [ ..len_encoded] . copy_from_slice ( encoded) ;
159
- } else {
160
- let mut hash_output = <Blake2x256 as HashOutput >:: Type :: default ( ) ;
161
- <Blake2x256 as CryptoHash >:: hash ( encoded, & mut hash_output) ;
162
- let copy_len = core:: cmp:: min ( hash_output. len ( ) , len_result) ;
163
- result. as_mut ( ) [ 0 ..copy_len] . copy_from_slice ( & hash_output[ 0 ..copy_len] ) ;
164
- }
169
+ let result = inner :: < E > ( encoded) ;
165
170
self . scoped_buffer . append_encoded ( & result) ;
166
171
}
167
172
0 commit comments