File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,21 @@ where
25
25
debug_assert ! ( size_of:: <T >( ) <= MAX_INT_SIZE ) ;
26
26
27
27
let mut buf1 = [ 0u8 ; MAX_INT_SIZE ] ;
28
- let mut encoder1 = SliceWriter :: new ( & mut buf1) ;
29
- a. encode_value ( & mut encoder1) ?;
30
-
31
28
let mut buf2 = [ 0u8 ; MAX_INT_SIZE ] ;
32
- let mut encoder2 = SliceWriter :: new ( & mut buf2) ;
33
- b. encode_value ( & mut encoder2) ?;
34
29
35
- Ok ( encoder1. finish ( ) ?. cmp ( encoder2. finish ( ) ?) )
30
+ let buf1 = encode_value_to_slice ( & mut buf1, & a) ?;
31
+ let buf2 = encode_value_to_slice ( & mut buf2, & b) ?;
32
+
33
+ Ok ( buf1. cmp ( buf2) )
34
+ }
35
+
36
+ fn encode_value_to_slice < ' a , T > ( buf : & ' a mut [ u8 ] , value : & T ) -> Result < & ' a [ u8 ] >
37
+ where
38
+ T : EncodeValue ,
39
+ {
40
+ let mut encoder = SliceWriter :: new ( buf) ;
41
+ value. encode_value ( & mut encoder) ?;
42
+ encoder. finish ( )
36
43
}
37
44
38
45
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments