File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ exclude = ["/assets"]
1616description = " Fast and memory saving bsdiff 4.x compatible delta compressor and patcher."
1717
1818[dependencies ]
19- byteorder = " 1.5"
2019bzip2 = " 0.6.0"
2120clap = { optional = true , version = " 4.5" , features = [" derive" ] }
2221rayon = " 1.10"
Original file line number Diff line number Diff line change 11#![ forbid( unsafe_code) ]
22
3- use byteorder:: { ByteOrder , LE } ;
4-
53/// Single bsdiff control instruction.
64#[ derive( Debug ) ]
75pub struct Control {
@@ -13,7 +11,7 @@ pub struct Control {
1311/// Decodes integer.
1412#[ inline]
1513pub fn decode_int ( b : & [ u8 ] ) -> i64 {
16- let x = LE :: read_u64 ( b ) ;
14+ let x = u64 :: from_le_bytes ( b [ .. 8 ] . try_into ( ) . unwrap ( ) ) ;
1715 if x >> 63 == 0 || x == 1 << 63 {
1816 x as i64
1917 } else {
@@ -24,9 +22,12 @@ pub fn decode_int(b: &[u8]) -> i64 {
2422/// Encodes integer.
2523#[ inline]
2624pub fn encode_int ( x : i64 , b : & mut [ u8 ] ) {
27- if x < 0 {
28- LE :: write_u64 ( b , x. wrapping_neg ( ) as u64 | ( 1 << 63 ) ) ;
25+ let n = if x < 0 {
26+ x. wrapping_neg ( ) as u64 | ( 1 << 63 )
2927 } else {
30- LE :: write_u64 ( b, x as u64 ) ;
31- }
28+ x as u64
29+ } ;
30+
31+ let buf = n. to_le_bytes ( ) ;
32+ b[ ..8 ] . copy_from_slice ( & buf) ;
3233}
You can’t perform that action at this time.
0 commit comments