Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Aug 21, 2024
1 parent 6a85038 commit 170ffb4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/ruff_db/src/vendored.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ impl VendoredFileSystem {
let mut archive = fs.lock_archive();
let mut zip_file = archive.lookup_path(&NormalizedVendoredPath::from(path))?;

// Pre-allocate the buffer with the size specified in the ZIP file metadata
// because `read_to_string` passes `None` as the size hint.
// But let's not trust the zip file metadata (even though it's vendored)
// and limit it to a reasonable size.
let mut buffer = String::with_capacity(
usize::try_from(zip_file.size())
.unwrap_or(usize::MAX)
Expand Down

0 comments on commit 170ffb4

Please sign in to comment.