diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-08-12 13:04:45 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-12 19:04:45 +0000 |
commit | babfba14ef327051a1caf9df6730606330ff1cc0 (patch) | |
tree | 75734629f03282488b2ff3271aa0d96db0e7037d /ext/io/fs.rs | |
parent | 050ca394096d22330bf5519aad2c59f84be7a0c2 (diff) |
chore: deno_core -> 0.201.0 (#20135)
Diffstat (limited to 'ext/io/fs.rs')
-rw-r--r-- | ext/io/fs.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/ext/io/fs.rs b/ext/io/fs.rs index 1ebe0e7c1..3c98bf861 100644 --- a/ext/io/fs.rs +++ b/ext/io/fs.rs @@ -170,14 +170,10 @@ impl FsStat { pub trait File { fn read_sync(self: Rc<Self>, buf: &mut [u8]) -> FsResult<usize>; async fn read(self: Rc<Self>, limit: usize) -> FsResult<BufView> { - let vec = vec![0; limit]; - let buf = BufMutView::from(vec); - let (nread, buf) = self.read_byob(buf).await?; - let mut vec = buf.unwrap_vec(); - if vec.len() != nread { - vec.truncate(nread); - } - Ok(BufView::from(vec)) + let buf = BufMutView::new(limit); + let (nread, mut buf) = self.read_byob(buf).await?; + buf.truncate(nread); + Ok(buf.into_view()) } async fn read_byob( self: Rc<Self>, |