mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
chore: reduce allocations in a few places (#27288)
Probably doesn't have much impact. I didn't measure any of these, but reducing allocations should always be good.
This commit is contained in:
parent
d410358789
commit
c402448061
7 changed files with 54 additions and 26 deletions
|
@ -219,8 +219,9 @@ fn get_atomic_dir_path(file_path: &Path) -> PathBuf {
|
|||
}
|
||||
|
||||
fn gen_rand_path_component() -> String {
|
||||
(0..4).fold(String::new(), |mut output, _| {
|
||||
output.push_str(&format!("{:02x}", rand::random::<u8>()));
|
||||
use std::fmt::Write;
|
||||
(0..4).fold(String::with_capacity(8), |mut output, _| {
|
||||
write!(&mut output, "{:02x}", rand::random::<u8>()).unwrap();
|
||||
output
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue