Skip to content

Commit 61d4c9f

Browse files
committed
fix!: use dyn trait where possible.
This reduces compile time due to avoiding duplication.
1 parent 2b5da93 commit 61d4c9f

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

gix-features/src/cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ mod impl_ {
1111
impl Debug {
1212
/// Create a new instance
1313
#[inline]
14-
pub fn new(owner: impl Into<String>) -> Self {
14+
pub fn new(owner: String) -> Self {
1515
Debug {
16-
owner: owner.into(),
16+
owner,
1717
hits: 0,
1818
puts: 0,
1919
misses: 0,
@@ -61,7 +61,7 @@ mod impl_ {
6161
impl Debug {
6262
/// Create a new instance
6363
#[inline]
64-
pub fn new(_owner: impl Into<String>) -> Self {
64+
pub fn new(_owner: String) -> Self {
6565
Debug
6666
}
6767
/// noop

gix-features/src/fs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ pub mod walkdir {
5858
}
5959

6060
/// Instantiate a new directory iterator which will not skip hidden files, with the given level of `parallelism`.
61-
pub fn walkdir_new(root: impl AsRef<Path>, parallelism: Parallelism) -> WalkDir {
61+
pub fn walkdir_new(root: &Path, parallelism: Parallelism) -> WalkDir {
6262
WalkDir::new(root).skip_hidden(false).parallelism(parallelism.into())
6363
}
6464

6565
/// Instantiate a new directory iterator which will not skip hidden files and is sorted
66-
pub fn walkdir_sorted_new(root: impl AsRef<Path>, parallelism: Parallelism) -> WalkDir {
66+
pub fn walkdir_sorted_new(root: &Path, parallelism: Parallelism) -> WalkDir {
6767
WalkDir::new(root)
6868
.skip_hidden(false)
6969
.sort(true)
@@ -84,12 +84,12 @@ pub mod walkdir {
8484
pub use super::shared::Parallelism;
8585

8686
/// Instantiate a new directory iterator which will not skip hidden files, with the given level of `parallelism`.
87-
pub fn walkdir_new(root: impl AsRef<Path>, _: Parallelism) -> WalkDir {
87+
pub fn walkdir_new(root: &Path, _: Parallelism) -> WalkDir {
8888
WalkDir::new(root)
8989
}
9090

9191
/// Instantiate a new directory iterator which will not skip hidden files and is sorted, with the given level of `parallelism`.
92-
pub fn walkdir_sorted_new(root: impl AsRef<Path>, _: Parallelism) -> WalkDir {
92+
pub fn walkdir_sorted_new(root: &Path, _: Parallelism) -> WalkDir {
9393
WalkDir::new(root).sort_by_file_name()
9494
}
9595

gix-features/src/hash.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ pub fn hasher(kind: gix_hash::Kind) -> Sha1 {
9595
/// * [Interrupts][crate::interrupt] are supported.
9696
#[cfg(all(feature = "progress", any(feature = "rustsha1", feature = "fast-sha1")))]
9797
pub fn bytes_of_file(
98-
path: impl AsRef<std::path::Path>,
98+
path: &std::path::Path,
9999
num_bytes_from_start: usize,
100100
kind: gix_hash::Kind,
101101
progress: &mut impl crate::progress::Progress,
102102
should_interrupt: &std::sync::atomic::AtomicBool,
103103
) -> std::io::Result<gix_hash::ObjectId> {
104104
bytes(
105-
std::fs::File::open(path)?,
105+
&mut std::fs::File::open(path)?,
106106
num_bytes_from_start,
107107
kind,
108108
progress,
@@ -113,7 +113,7 @@ pub fn bytes_of_file(
113113
/// Similar to [`bytes_of_file`], but operates on an already open file.
114114
#[cfg(all(feature = "progress", any(feature = "rustsha1", feature = "fast-sha1")))]
115115
pub fn bytes(
116-
mut read: impl std::io::Read,
116+
read: &mut dyn std::io::Read,
117117
num_bytes_from_start: usize,
118118
kind: gix_hash::Kind,
119119
progress: &mut impl crate::progress::Progress,

gix-features/src/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ pub mod pipe {
7777
/// Returns the _([`write`][Writer], [`read`][Reader])_ ends of a pipe for transferring bytes, analogous to a unix pipe.
7878
///
7979
/// * `in_flight_writes` defines the amount of chunks of bytes to keep in memory until the `write` end will block when writing.
80-
/// If `None` or `0`, the `write` end will always block until the `read` end consumes the transferred bytes.
81-
pub fn unidirectional(in_flight_writes: impl Into<Option<usize>>) -> (Writer, Reader) {
82-
let (tx, rx) = std::sync::mpsc::sync_channel(in_flight_writes.into().unwrap_or(0));
80+
/// If `0`, the `write` end will always block until the `read` end consumes the transferred bytes.
81+
pub fn unidirectional(in_flight_writes: usize) -> (Writer, Reader) {
82+
let (tx, rx) = std::sync::mpsc::sync_channel(in_flight_writes);
8383
(
8484
Writer {
8585
channel: tx,

gix-features/tests/pipe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod io {
2222

2323
#[test]
2424
fn lack_of_reader_fails_with_broken_pipe() {
25-
let (mut writer, _) = io::pipe::unidirectional(None);
25+
let (mut writer, _) = io::pipe::unidirectional(0);
2626
assert_eq!(
2727
writer.write_all(b"must fail").unwrap_err().kind(),
2828
ErrorKind::BrokenPipe
@@ -96,7 +96,7 @@ mod io {
9696
fn small_reads() {
9797
const BLOCK_SIZE: usize = 20;
9898
let block_count = 20;
99-
let (mut writer, mut reader) = io::pipe::unidirectional(Some(4));
99+
let (mut writer, mut reader) = io::pipe::unidirectional(4);
100100
std::thread::spawn(move || {
101101
for _ in 0..block_count {
102102
let data = &[0; BLOCK_SIZE];

0 commit comments

Comments
 (0)