11

Github Avoid unnecessary Vec construction in BufReader by calebsander · Pull Req...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/82728
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

calebsander commented 11 days ago

As mentioned in #80460, creating a Vec and calling Vec::into_boxed_slice() emits unnecessary calls to realloc() and free(). Updated the code to use Box::new_uninit_slice() to create a boxed slice directly. I think this also makes it more explicit that the initial contents of the buffer are uninitialized.

r? @m-ou-se


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK