>>107717211
https://files.catbox.moe/hyn2wm
>>107717394
A Vec doesn't allocate until you write to it so on the mmap path it doesn't do anything. I define the variable in the top-level scope so it stays alive for long enough.
You could write this instead:
let mut input_buf;
let input_map = unsafe { memmap2::Mmap::map(&io::stdin()) };
let input: &[u8] = if let Ok(input_map) = &input_map {
input_map
} else {
input_buf = Vec::new();
io::stdin().read_to_end(&mut input_buf)?;
&input_buf
};
Comment too long. Click here to view the full text.