Skip to content

Commit 40f9d79

Browse files
committed
chore: add some #[inline]
Resolves #300
1 parent 9d4eaa3 commit 40f9d79

21 files changed

Lines changed: 58 additions & 0 deletions

src/app.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ impl App {
155155
impl GetSizeUtils for GetApparentSize {
156156
const INSTANCE: Self = GetApparentSize;
157157
const QUANTITY: Quantity = Quantity::ApparentSize;
158+
#[inline]
158159
fn formatter(bytes_format: BytesFormat) -> BytesFormat {
159160
bytes_format
160161
}
@@ -164,6 +165,7 @@ impl App {
164165
impl GetSizeUtils for GetBlockSize {
165166
const INSTANCE: Self = GetBlockSize;
166167
const QUANTITY: Quantity = Quantity::BlockSize;
168+
#[inline]
167169
fn formatter(bytes_format: BytesFormat) -> BytesFormat {
168170
bytes_format
169171
}
@@ -173,6 +175,7 @@ impl App {
173175
impl GetSizeUtils for GetBlockCount {
174176
const INSTANCE: Self = GetBlockCount;
175177
const QUANTITY: Quantity = Quantity::BlockCount;
178+
#[inline]
176179
fn formatter(_: BytesFormat) {}
177180
}
178181

@@ -186,6 +189,7 @@ impl App {
186189
Self: GetSizeUtils,
187190
{
188191
type Reporter = ErrorOnlyReporter<fn(ErrorReport)>;
192+
#[inline]
189193
fn create_reporter(report_error: fn(ErrorReport)) -> Self::Reporter {
190194
ErrorOnlyReporter::new(report_error)
191195
}
@@ -199,6 +203,7 @@ impl App {
199203
u64: Into<Self::Size>,
200204
{
201205
type Reporter = ProgressAndErrorReporter<Self::Size, fn(ErrorReport)>;
206+
#[inline]
202207
fn create_reporter(report_error: fn(ErrorReport)) -> Self::Reporter {
203208
ProgressAndErrorReporter::new(
204209
ProgressReport::TEXT,
@@ -223,6 +228,7 @@ impl App {
223228
Self::Size: Send + Sync,
224229
{
225230
type HardlinksHandler = hardlink::HardlinkIgnorant;
231+
#[inline]
226232
fn create_hardlinks_handler() -> Self::HardlinksHandler {
227233
hardlink::HardlinkIgnorant
228234
}
@@ -237,6 +243,7 @@ impl App {
237243
Self::Reporter: crate::reporter::Reporter<Self::Size>,
238244
{
239245
type HardlinksHandler = hardlink::HardlinkAware<Self::Size>;
246+
#[inline]
240247
fn create_hardlinks_handler() -> Self::HardlinksHandler {
241248
hardlink::HardlinkAware::new()
242249
}

src/app/hdd.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ pub struct RealApi;
1919
impl Api for RealApi {
2020
type Disk = Disk;
2121

22+
#[inline]
2223
fn get_disk_kind(disk: &Self::Disk) -> DiskKind {
2324
disk.kind()
2425
}
2526

27+
#[inline]
2628
fn get_mount_point(disk: &Self::Disk) -> &Path {
2729
disk.mount_point()
2830
}
2931

32+
#[inline]
3033
fn canonicalize(path: &Path) -> io::Result<PathBuf> {
3134
canonicalize(path)
3235
}

src/app/overlapping_arguments.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ impl Api for RealApi {
2424
type RealPath = PathBuf;
2525
type RealPathError = io::Error;
2626

27+
#[inline]
2728
fn canonicalize(path: &Self::Argument) -> Result<Self::RealPath, Self::RealPathError> {
2829
canonicalize(path)
2930
}
3031

32+
#[inline]
3133
fn is_real_dir(path: &Self::Argument) -> bool {
3234
path.pipe(symlink_metadata)
3335
.is_ok_and(|metadata| !metadata.is_symlink() && metadata.is_dir())
3436
}
3537

38+
#[inline]
3639
fn starts_with(a: &Self::RealPath, b: &Self::RealPath) -> bool {
3740
a.starts_with(b)
3841
}

src/app/sub.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,17 @@ where
246246
DataTree<OsStringDisplay, Size>: Send,
247247
Size: size::Size + Sync,
248248
{
249+
#[inline]
249250
fn convert_error(error: Self::Error) -> RuntimeError {
250251
match error {}
251252
}
252253

254+
#[inline]
253255
fn print_report((): Self::Report, _: Size::DisplayFormat) -> Result<(), RuntimeError> {
254256
Ok(())
255257
}
256258

259+
#[inline]
257260
fn json_report((): Self::Report) -> Result<Option<JsonShared<Size>>, RuntimeError> {
258261
Ok(None)
259262
}

src/bytes_format/formatter.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ pub struct Formatter {
99

1010
impl Formatter {
1111
/// Create a new formatter.
12+
#[inline]
1213
pub const fn new(scale_base: u64) -> Self {
1314
Formatter { scale_base }
1415
}
1516

1617
/// Multiplication factor.
18+
#[inline]
1719
pub const fn scale_base(self) -> u64 {
1820
self.scale_base
1921
}
2022

2123
/// Get scale in number.
24+
#[inline]
2225
pub const fn scale(self, exp: u32) -> u64 {
2326
self.scale_base().pow(exp)
2427
}

src/data_tree/constructors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::size;
33

44
impl<Name, Size: size::Size> DataTree<Name, Size> {
55
/// Create a tree representation of a directory.
6+
#[inline]
67
pub fn dir(name: Name, inode_size: Size, children: Vec<Self>) -> Self {
78
let size = inode_size + children.iter().map(DataTree::size).sum();
89
DataTree {
@@ -13,6 +14,7 @@ impl<Name, Size: size::Size> DataTree<Name, Size> {
1314
}
1415

1516
/// Create a tree representation of a file.
17+
#[inline]
1618
pub fn file(name: Name, size: Size) -> Self {
1719
DataTree {
1820
name,
@@ -22,6 +24,7 @@ impl<Name, Size: size::Size> DataTree<Name, Size> {
2224
}
2325

2426
/// Create a directory constructor of fixed inode size.
27+
#[inline]
2528
pub fn fixed_size_dir_constructor(inode_size: Size) -> impl Fn(Name, Vec<Self>) -> Self
2629
where
2730
Size: Copy,

src/data_tree/getters.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ use crate::size;
33

44
impl<Name, Size: size::Size> DataTree<Name, Size> {
55
/// Extract name
6+
#[inline]
67
pub fn name(&self) -> &Name {
78
&self.name
89
}
910

1011
/// Get mutable reference to name.
12+
#[inline]
1113
pub fn name_mut(&mut self) -> &mut Name {
1214
&mut self.name
1315
}
1416

1517
/// Extract total disk usage
18+
#[inline]
1619
pub fn size(&self) -> Size {
1720
self.size
1821
}
1922

2023
/// Extract children
24+
#[inline]
2125
pub fn children(&self) -> &Vec<Self> {
2226
&self.children
2327
}

src/data_tree/reflection/convert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl<Name, Size: size::Size> From<DataTree<Name, Size>> for Reflection<Name, Siz
1919

2020
impl<Name, Size: size::Size> DataTree<Name, Size> {
2121
/// Create reflection.
22+
#[inline]
2223
pub fn into_reflection(self) -> Reflection<Name, Size> {
2324
self.into()
2425
}

src/data_tree/sort.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ where
1717
}
1818

1919
/// Process the tree via [`par_sort_by`](Self::par_sort_by) method.
20+
#[inline]
2021
pub fn into_par_sorted(
2122
mut self,
2223
compare: impl Fn(&Self, &Self) -> Ordering + Copy + Sync,

src/get_size.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub trait GetSize {
1717
pub struct GetApparentSize;
1818
impl GetSize for GetApparentSize {
1919
type Size = Bytes;
20+
#[inline]
2021
fn get_size(&self, metadata: &Metadata) -> Self::Size {
2122
metadata.len().into()
2223
}
@@ -29,6 +30,7 @@ pub struct GetBlockSize;
2930
#[cfg(unix)]
3031
impl GetSize for GetBlockSize {
3132
type Size = Bytes;
33+
#[inline]
3234
fn get_size(&self, metadata: &Metadata) -> Self::Size {
3335
(metadata.blocks() * 512).into()
3436
}
@@ -41,6 +43,7 @@ pub struct GetBlockCount;
4143
#[cfg(unix)]
4244
impl GetSize for GetBlockCount {
4345
type Size = Blocks;
46+
#[inline]
4447
fn get_size(&self, metadata: &Metadata) -> Self::Size {
4548
metadata.blocks().into()
4649
}

0 commit comments

Comments
 (0)