From 40a8d6d9298e17a03560a7b88d397a4e0bee503a Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Tue, 31 Dec 2024 10:48:10 +0100 Subject: [PATCH] Some cleanup --- src/main/rust/benches/flare_flo.rs | 2 +- src/main/rust/benches/libraries.rs | 2 +- src/main/rust/benches/multi_threaded.rs | 2 +- src/main/rust/benches/multi_threaded_smol.rs | 2 +- src/main/rust/benches/phcs.rs | 2 +- src/main/rust/benches/reference_impl.rs | 2 +- src/main/rust/benches/single_thread.rs | 2 +- src/main/rust/src/models/mmap.rs | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/rust/benches/flare_flo.rs b/src/main/rust/benches/flare_flo.rs index 07e6a32..26bdbb7 100644 --- a/src/main/rust/benches/flare_flo.rs +++ b/src/main/rust/benches/flare_flo.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use onebrc::implementations::flare_flo::run; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("flareflo", |b| b.iter(|| run())); + c.bench_function("flareflo", |b| b.iter(run)); } criterion_group!(benches, criterion_benchmark); diff --git a/src/main/rust/benches/libraries.rs b/src/main/rust/benches/libraries.rs index 8d4ccad..5261e5a 100644 --- a/src/main/rust/benches/libraries.rs +++ b/src/main/rust/benches/libraries.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use onebrc::implementations::libraries::run; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("libraries", |b| b.iter(|| run())); + c.bench_function("libraries", |b| b.iter(run)); } criterion_group!(benches, criterion_benchmark); diff --git a/src/main/rust/benches/multi_threaded.rs b/src/main/rust/benches/multi_threaded.rs index cde1ed2..dbf2bb1 100644 --- a/src/main/rust/benches/multi_threaded.rs +++ b/src/main/rust/benches/multi_threaded.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use onebrc::implementations::multi_threaded::run; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("multithreaded", |b| b.iter(|| run())); + c.bench_function("multithreaded", |b| b.iter(run)); } criterion_group!(benches, criterion_benchmark); diff --git a/src/main/rust/benches/multi_threaded_smol.rs b/src/main/rust/benches/multi_threaded_smol.rs index 1165256..4e47a53 100644 --- a/src/main/rust/benches/multi_threaded_smol.rs +++ b/src/main/rust/benches/multi_threaded_smol.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use onebrc::implementations::multi_threaded_smol::run; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("multithreadedsmol", |b| b.iter(|| run())); + c.bench_function("multithreadedsmol", |b| b.iter(run)); } criterion_group!(benches, criterion_benchmark); diff --git a/src/main/rust/benches/phcs.rs b/src/main/rust/benches/phcs.rs index 912abfe..e71f833 100644 --- a/src/main/rust/benches/phcs.rs +++ b/src/main/rust/benches/phcs.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use onebrc::implementations::phcs::run; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("phcs", |b| b.iter(|| run())); + c.bench_function("phcs", |b| b.iter(run)); } criterion_group!(benches, criterion_benchmark); diff --git a/src/main/rust/benches/reference_impl.rs b/src/main/rust/benches/reference_impl.rs index e7defc1..97d60e3 100644 --- a/src/main/rust/benches/reference_impl.rs +++ b/src/main/rust/benches/reference_impl.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use onebrc::implementations::reference_impl::run; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("reference", |b| b.iter(|| run())); + c.bench_function("reference", |b| b.iter(run)); } criterion_group!(benches, criterion_benchmark); diff --git a/src/main/rust/benches/single_thread.rs b/src/main/rust/benches/single_thread.rs index 420e2fa..e7f41a1 100644 --- a/src/main/rust/benches/single_thread.rs +++ b/src/main/rust/benches/single_thread.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use onebrc::implementations::single_thread::run; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("singlethread", |b| b.iter(|| run())); + c.bench_function("singlethread", |b| b.iter(run)); } criterion_group!(benches, criterion_benchmark); diff --git a/src/main/rust/src/models/mmap.rs b/src/main/rust/src/models/mmap.rs index 054ce74..2783349 100644 --- a/src/main/rust/src/models/mmap.rs +++ b/src/main/rust/src/models/mmap.rs @@ -12,7 +12,7 @@ pub struct Mmap<'a> { /// To properly dispose of the mmap we have to manually call munmap. /// So implementing drop for this smart-pointer type is necessary. -impl<'a> Drop for Mmap<'a> { +impl Drop for Mmap<'_> { fn drop(&mut self) { unsafe { munmap( @@ -25,7 +25,7 @@ impl<'a> Drop for Mmap<'a> { // anti-pattern for non-smart pointer types. // ref: https://rust-unofficial.github.io/patterns/anti_patterns/deref.html -impl<'a> Deref for Mmap<'a> { +impl Deref for Mmap<'_> { type Target = [u8]; fn deref(&self) -> &Self::Target { @@ -50,7 +50,7 @@ impl<'a> Mmap<'a> { // We can advise the kernel on how we intend to use the mmap. // But this did not improve my read performance in a meaningful way madvise(m, size, MADV_WILLNEED); - return Self::new(std::slice::from_raw_parts(m as *const u8, size)); + Self::new(std::slice::from_raw_parts(m as *const u8, size)) } } }