0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2025-02-01 12:15:46 -05:00

chore: cleanup format args

Manually clean up [`uninlined_format_args`](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) clippy lint.  Some of these changes cause about 5% performance improvements because `format!("{}", &var)` does not need a reference and cannot be optimized by the compiler (but in thees cases the perf difference is less important)
This commit is contained in:
Yuri Astrakhan 2025-02-01 01:37:41 -05:00
parent 5add1340f9
commit 81023afc5f
7 changed files with 18 additions and 24 deletions

View file

@ -134,7 +134,7 @@ fn acquire_lock() -> LockFile {
let mut lockfile = LockFile::open(&lockfilepath) let mut lockfile = LockFile::open(&lockfilepath)
.expect("Couldn't open lib download lockfile."); .expect("Couldn't open lib download lockfile.");
lockfile.lock_with_pid().expect("Couldn't get lock"); lockfile.lock_with_pid().expect("Couldn't get lock");
println!("lockfile: {:?}", &lockfilepath); println!("lockfile: {lockfilepath:?}");
lockfile lockfile
} }
@ -414,9 +414,7 @@ fn static_lib_url() -> String {
let target = env::var("TARGET").unwrap(); let target = env::var("TARGET").unwrap();
let profile = prebuilt_profile(); let profile = prebuilt_profile();
format!( format!(
"{}/v{}/{}.gz", "{base}/v{version}/{}.gz",
base,
version,
static_lib_name(&format!("_{profile}_{target}")), static_lib_name(&format!("_{profile}_{target}")),
) )
} }
@ -823,7 +821,7 @@ fn maybe_symlink_root_dir(dirs: &mut Dirs) {
let symlink = &*out.join("gn_root"); let symlink = &*out.join("gn_root");
let target = &*root.canonicalize().unwrap(); let target = &*root.canonicalize().unwrap();
println!("Creating symlink {:?} to {:?}", &symlink, &root); println!("Creating symlink {symlink:?} to {root:?}");
let mut retries = 0; let mut retries = 0;
loop { loop {
@ -831,19 +829,19 @@ fn maybe_symlink_root_dir(dirs: &mut Dirs) {
Ok(existing) if existing == target => break, Ok(existing) if existing == target => break,
Ok(_) => remove_dir_all(symlink).expect("remove_dir_all failed"), Ok(_) => remove_dir_all(symlink).expect("remove_dir_all failed"),
Err(err) => { Err(err) => {
println!("symlink.canonicalize failed: {:?}", err); println!("symlink.canonicalize failed: {err:?}");
// we're having very strange issues on GHA when the cache // we're having very strange issues on GHA when the cache
// is restored, so trying this out temporarily // is restored, so trying this out temporarily
if let Err(err) = remove_dir_all(symlink) { if let Err(err) = remove_dir_all(symlink) {
eprintln!("remove_dir_all failed: {:?}", err); eprintln!("remove_dir_all failed: {err:?}");
if let Err(err) = remove_file(symlink) { if let Err(err) = remove_file(symlink) {
eprintln!("remove_file failed: {:?}", err); eprintln!("remove_file failed: {err:?}");
} }
} }
match symlink_dir(target, symlink) { match symlink_dir(target, symlink) {
Ok(_) => break, Ok(_) => break,
Err(err) => { Err(err) => {
println!("symlink_dir failed: {:?}", err); println!("symlink_dir failed: {err:?}");
retries += 1; retries += 1;
std::thread::sleep(std::time::Duration::from_millis( std::thread::sleep(std::time::Duration::from_millis(
50 * retries, 50 * retries,
@ -915,7 +913,7 @@ pub fn maybe_gen(gn_args: GnArgs) -> PathBuf {
if !gn_out_dir.exists() || !gn_out_dir.join("build.ninja").exists() { if !gn_out_dir.exists() || !gn_out_dir.join("build.ninja").exists() {
let args = if let Ok(extra_args) = env::var("EXTRA_GN_ARGS") { let args = if let Ok(extra_args) = env::var("EXTRA_GN_ARGS") {
format!("{} {}", gn_args.join(" "), extra_args) format!("{} {extra_args}", gn_args.join(" "))
} else { } else {
gn_args.join(" ") gn_args.join(" ")
}; };

View file

@ -103,7 +103,7 @@ fn execute_script(
.map(|value| value.to_rust_string_lossy(try_catch)) .map(|value| value.to_rust_string_lossy(try_catch))
.unwrap_or_else(|| "no stack trace".into()); .unwrap_or_else(|| "no stack trace".into());
panic!("{}", exception_string); panic!("{exception_string}");
} }
} }
@ -128,7 +128,7 @@ fn draw(
.map(|value| value.to_rust_string_lossy(try_catch)) .map(|value| value.to_rust_string_lossy(try_catch))
.unwrap_or_else(|| "no stack trace".into()); .unwrap_or_else(|| "no stack trace".into());
panic!("{}", exception_string); panic!("{exception_string}");
} }
}; };

View file

@ -120,6 +120,6 @@ fn execute_script(
.map(|value| value.to_rust_string_lossy(try_catch)) .map(|value| value.to_rust_string_lossy(try_catch))
.unwrap_or_else(|| "no stack trace".into()); .unwrap_or_else(|| "no stack trace".into());
panic!("{}", exception_string); panic!("{exception_string}");
} }
} }

View file

@ -223,7 +223,7 @@ where
.unwrap() .unwrap()
.to_rust_string_lossy(try_catch); .to_rust_string_lossy(try_catch);
panic!("{}", exception_string); panic!("{exception_string}");
} }
} }
@ -251,7 +251,7 @@ where
.unwrap() .unwrap()
.to_rust_string_lossy(try_catch); .to_rust_string_lossy(try_catch);
panic!("{}", exception_string); panic!("{exception_string}");
} }
} }

View file

@ -360,13 +360,10 @@ fn assert_shared_ptr_use_count_eq<T: Shared>(
}; };
assert!( assert!(
ok, ok,
"assertion failed: `{}<{}>` reference count does not match expectation\ "assertion failed: `{wrapper_type_name}<{}>` reference count does not match expectation\
\n actual: {}\ \n actual: {actual}\
\n expected: {}", \n expected: {expected}",
wrapper_type_name,
type_name::<T>(), type_name::<T>(),
actual,
expected
); );
} }

View file

@ -6696,8 +6696,7 @@ impl v8::inspector::ChannelImpl for ChannelCounter {
message: v8::UniquePtr<v8::inspector::StringBuffer>, message: v8::UniquePtr<v8::inspector::StringBuffer>,
) { ) {
println!( println!(
"send_response call_id {} message {}", "send_response call_id {call_id} message {}",
call_id,
message.unwrap().string() message.unwrap().string()
); );
self.count_send_response += 1; self.count_send_response += 1;

View file

@ -236,6 +236,6 @@ fn execute_script(
.map(|value| value.to_rust_string_lossy(scope)) .map(|value| value.to_rust_string_lossy(scope))
.unwrap_or_else(|| "no stack trace".into()); .unwrap_or_else(|| "no stack trace".into());
panic!("{}", exception_string); panic!("{exception_string}");
} }
} }