@@ -6,12 +6,7 @@ pub struct Window<'a> {
6
6
// perform bounds checks.
7
7
buf : WeakSliceMut < ' a , u8 > ,
8
8
9
- // number of initialized bytes
10
- filled : usize ,
11
-
12
9
window_bits : usize ,
13
-
14
- high_water : usize ,
15
10
}
16
11
17
12
impl < ' a > Window < ' a > {
@@ -21,12 +16,7 @@ impl<'a> Window<'a> {
21
16
// SAFETY: freshly allocated buffer
22
17
let buf = unsafe { WeakSliceMut :: from_raw_parts_mut ( ptr, len) } ;
23
18
24
- Some ( Self {
25
- buf,
26
- filled : len,
27
- window_bits,
28
- high_water : len,
29
- } )
19
+ Some ( Self { buf, window_bits } )
30
20
}
31
21
32
22
pub fn clone_in ( & self , alloc : & Allocator < ' a > ) -> Option < Self > {
@@ -36,8 +26,6 @@ impl<'a> Window<'a> {
36
26
. buf
37
27
. as_mut_slice ( )
38
28
. copy_from_slice ( self . buf . as_slice ( ) ) ;
39
- clone. filled = self . filled ;
40
- clone. high_water = self . high_water ;
41
29
42
30
Some ( clone)
43
31
}
@@ -60,14 +48,14 @@ impl<'a> Window<'a> {
60
48
#[ inline]
61
49
pub fn filled ( & self ) -> & [ u8 ] {
62
50
// SAFETY: `self.buf` has been initialized for at least `filled` elements
63
- unsafe { core:: slice:: from_raw_parts ( self . buf . as_ptr ( ) . cast ( ) , self . filled ) }
51
+ unsafe { core:: slice:: from_raw_parts ( self . buf . as_ptr ( ) . cast ( ) , self . buf . len ( ) ) }
64
52
}
65
53
66
54
/// Returns a mutable reference to the filled portion of the buffer.
67
55
#[ inline]
68
56
pub fn filled_mut ( & mut self ) -> & mut [ u8 ] {
69
57
// SAFETY: `self.buf` has been initialized for at least `filled` elements
70
- unsafe { core:: slice:: from_raw_parts_mut ( self . buf . as_mut_ptr ( ) . cast ( ) , self . filled ) }
58
+ unsafe { core:: slice:: from_raw_parts_mut ( self . buf . as_mut_ptr ( ) . cast ( ) , self . buf . len ( ) ) }
71
59
}
72
60
73
61
/// # Safety
@@ -78,23 +66,8 @@ impl<'a> Window<'a> {
78
66
79
67
let dst = self . buf . as_mut_slice ( ) [ range] . as_mut_ptr ( ) as * mut u8 ;
80
68
unsafe { core:: ptr:: copy_nonoverlapping ( src, dst, end - start) } ;
81
-
82
- if start >= self . filled {
83
- self . filled = Ord :: max ( self . filled , end) ;
84
- }
85
-
86
- self . high_water = Ord :: max ( self . high_water , self . filled ) ;
87
69
}
88
70
89
- // this library has many functions that operated in a chunked fashion on memory. For
90
- // performance, we want to minimize bounds checks. Therefore we reserve initialize some extra
91
- // memory at the end of the window so that chunked operations can use the whole buffer. If they
92
- // go slightly over `self.capacity` that's okay, we account for that here by making sure the
93
- // memory there is initialized!
94
- pub fn initialize_out_of_bounds ( & mut self ) { }
95
-
96
- pub fn initialize_at_least ( & mut self , at_least : usize ) { }
97
-
98
71
// padding required so that SIMD operations going out-of-bounds are not a problem
99
72
pub fn padding ( ) -> usize {
100
73
if crate :: cpu_features:: is_enabled_pclmulqdq ( ) {
0 commit comments