Commit 0d54cf0 1 parent b5611a2 commit 0d54cf0 Copy full SHA for 0d54cf0
File tree 2 files changed +10
-3
lines changed
quickwit/quickwit-storage/src
2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,11 @@ impl SplitFile {
160
160
use std:: os:: unix:: fs:: FileExt ;
161
161
let file = self . clone ( ) ;
162
162
let buf = tokio:: task:: spawn_blocking ( move || {
163
- let mut buf = vec ! [ 0u8 ; range. len( ) ] ;
163
+ let mut buf = Vec :: with_capacity ( range. len ( ) ) ;
164
+ #[ allow( clippy:: uninit_vec) ]
165
+ unsafe {
166
+ buf. set_len ( range. len ( ) ) ;
167
+ }
164
168
file. 0 . file . read_exact_at ( & mut buf, range. start as u64 ) ?;
165
169
io:: Result :: Ok ( buf)
166
170
} )
Original file line number Diff line number Diff line change @@ -215,12 +215,15 @@ impl Storage for LocalFileStorage {
215
215
let full_path = self . full_path ( path) ?;
216
216
tokio:: task:: spawn_blocking ( move || {
217
217
use std:: io:: { Read , Seek } ;
218
-
219
218
// we run these io in a spawn_blocking so there is no scheduling delay between each
220
219
// step, as there would be if using tokio async File.
221
220
let mut file = std:: fs:: File :: open ( full_path) ?;
222
221
file. seek ( SeekFrom :: Start ( range. start as u64 ) ) ?;
223
- let mut content_bytes: Vec < u8 > = vec ! [ 0u8 ; range. len( ) ] ;
222
+ let mut content_bytes: Vec < u8 > = Vec :: with_capacity ( range. len ( ) ) ;
223
+ #[ allow( clippy:: uninit_vec) ]
224
+ unsafe {
225
+ content_bytes. set_len ( range. len ( ) ) ;
226
+ }
224
227
file. read_exact ( & mut content_bytes) ?;
225
228
Ok ( OwnedBytes :: new ( content_bytes) )
226
229
} )
You can’t perform that action at this time.
0 commit comments