Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Hoffmann <[email protected]>
  • Loading branch information
antiguru committed Feb 8, 2024
1 parent df7b24f commit 5b62c23
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
12 changes: 9 additions & 3 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

extern crate test;

use flatcontainer::{Containerized, CopyOnto, CopyRegion, FlatStack, MirrorRegion, Region, ReserveItems, SliceRegion, StringRegion};
use test::Bencher;
use flatcontainer::impls::tuple::TupleABCRegion;
use flatcontainer::{
Containerized, CopyOnto, CopyRegion, FlatStack, MirrorRegion, Region, ReserveItems,
SliceRegion, StringRegion,
};
use test::Bencher;

#[bench]
fn empty_copy(bencher: &mut Bencher) {
Expand Down Expand Up @@ -92,7 +95,10 @@ fn vec_u_s_copy_region(bencher: &mut Bencher) {
}
#[bench]
fn vec_u_vn_s_copy_region(bencher: &mut Bencher) {
_bench_copy_region::<SliceRegion<SliceRegion<TupleABCRegion<MirrorRegion<_>, CopyRegion<_>, StringRegion>>>, _>(
_bench_copy_region::<
SliceRegion<SliceRegion<TupleABCRegion<MirrorRegion<_>, CopyRegion<_>, StringRegion>>>,
_,
>(
bencher,
vec![vec![(0u64, vec![(); 1 << 40], "grawwwwrr!".to_string()); 32]; 32],
);
Expand Down
12 changes: 6 additions & 6 deletions src/impls/slice_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ where

impl<T: Copy> ReserveItems<CopyRegion<T>> for &[T] {
fn reserve_items<I>(target: &mut CopyRegion<T>, items: I)
where
I: Iterator<Item = Self> + Clone,
where
I: Iterator<Item = Self> + Clone,
{
target.slices.reserve(items.clone().map(|i| i.len()).sum());
}
}

impl<T> CopyOnto<CopyRegion<T>> for &Vec<T>
where
T: Copy,
where
T: Copy,
{
fn copy_onto(self, target: &mut CopyRegion<T>) -> <CopyRegion<T> as Region>::Index {
let start = target.slices.len();
Expand All @@ -92,8 +92,8 @@ impl<T> CopyOnto<CopyRegion<T>> for &Vec<T>

impl<T: Copy> ReserveItems<CopyRegion<T>> for &Vec<T> {
fn reserve_items<I>(target: &mut CopyRegion<T>, items: I)
where
I: Iterator<Item = Self> + Clone,
where
I: Iterator<Item = Self> + Clone,
{
target.slices.reserve(items.clone().map(|i| i.len()).sum());
}
Expand Down
4 changes: 2 additions & 2 deletions src/impls/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ impl CopyOnto<StringRegion> for &&str {

impl ReserveItems<StringRegion> for &str {
fn reserve_items<I>(target: &mut StringRegion, items: I)
where
I: Iterator<Item = Self> + Clone,
where
I: Iterator<Item = Self> + Clone,
{
ReserveItems::reserve_items(&mut target.inner, items.map(str::as_bytes))
}
Expand Down

0 comments on commit 5b62c23

Please sign in to comment.