We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f5844e7 commit 23e2307Copy full SHA for 23e2307
crates/superblock/src/lib.rs
@@ -188,9 +188,10 @@ impl Superblock {
188
/// Note: This will read the minimum necessary bytes to detect the superblock,
189
/// which is more efficient than reading the entire device.
190
pub fn from_reader<R: Read + Seek>(reader: &mut R) -> Result<Self, Error> {
191
- let mut bytes = Vec::with_capacity(128 * 1024); // 128KB should cover all superblock offsets
+ // Preallocate a fixed buffer for the largest superblock we need to read
192
+ let mut bytes = vec![0u8; 128 * 1024]; // 128KB covers all superblock offsets
193
reader.rewind()?;
- reader.read_to_end(&mut bytes)?;
194
+ reader.read_exact(&mut bytes)?;
195
196
Self::from_bytes(&bytes)
197
}
0 commit comments