Small optimisations

Summary: We're passing around PathBufs where Paths are enough and more efficient.

Reviewed By: fabiomassimo

Differential Revision: D27155300

fbshipit-source-id: cdf8d67e28a669130482d333c960d100bdaf0992
This commit is contained in:
Pascal Hartig
2021-03-18 05:10:34 -07:00
committed by Facebook GitHub Bot
parent 844c3e3a1c
commit f04c8e8e2c

View File

@@ -56,9 +56,9 @@ fn default_progress_bar(len: u64) -> indicatif::ProgressBar {
fn pack( fn pack(
platform: Platform, platform: Platform,
dist_dir: &std::path::PathBuf, dist_dir: &std::path::Path,
pack_list: &PackList, pack_list: &PackList,
output_directory: &std::path::PathBuf, output_directory: &std::path::Path,
) -> Result<Vec<(PackType, path::PathBuf)>> { ) -> Result<Vec<(PackType, path::PathBuf)>> {
let pb = default_progress_bar(pack_list.0.len() as u64 * 2 - 1); let pb = default_progress_bar(pack_list.0.len() as u64 * 2 - 1);
pb.set_prefix(&format!( pb.set_prefix(&format!(
@@ -96,10 +96,10 @@ fn pack(
res res
} }
fn pack_platform( fn pack_platform<P: AsRef<path::Path>>(
platform: Platform, platform: Platform,
dist_dir: &std::path::PathBuf, dist_dir: &std::path::Path,
pack_files: &[path::PathBuf], pack_files: &[P],
pack_type: PackType, pack_type: PackType,
tar_builder: &mut tar::Builder<File>, tar_builder: &mut tar::Builder<File>,
) -> Result<()> { ) -> Result<()> {
@@ -240,14 +240,14 @@ fn compress_paths(
fn manifest( fn manifest(
archive_paths: &[(PackType, path::PathBuf)], archive_paths: &[(PackType, path::PathBuf)],
compressed_archive_paths: &Option<Vec<(PackType, path::PathBuf)>>, compressed_archive_paths: &Option<Vec<(PackType, path::PathBuf)>>,
output_directory: &path::PathBuf, output_directory: &path::Path,
) -> Result<path::PathBuf> { ) -> Result<path::PathBuf> {
let archive_manifest = gen_manifest(archive_paths, compressed_archive_paths)?; let archive_manifest = gen_manifest(archive_paths, compressed_archive_paths)?;
write_manifest(output_directory, &archive_manifest) write_manifest(output_directory, &archive_manifest)
} }
fn write_manifest( fn write_manifest(
output_directory: &path::PathBuf, output_directory: &path::Path,
archive_manifest: &PackManifest, archive_manifest: &PackManifest,
) -> Result<path::PathBuf> { ) -> Result<path::PathBuf> {
let path = path::PathBuf::from(output_directory).join("manifest.json"); let path = path::PathBuf::from(output_directory).join("manifest.json");