From 3c03538e0e0c691cdcc5dd4604a31af03e94bc4c Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Fri, 28 Oct 2022 18:28:55 +0800 Subject: [PATCH] chore: cargo style fix --- crates/loro-core/benches/text.rs | 42 +++++++++++-------- crates/loro-core/src/isomorph.rs | 1 + crates/loro-core/src/log_store.rs | 1 - crates/rle/src/range_map.rs | 7 ++-- crates/rle/src/rle_tree/node/internal_impl.rs | 2 +- justfile | 4 +- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/crates/loro-core/benches/text.rs b/crates/loro-core/benches/text.rs index 0681d378..8cb20dd7 100644 --- a/crates/loro-core/benches/text.rs +++ b/crates/loro-core/benches/text.rs @@ -1,23 +1,31 @@ -use arbitrary::Unstructured; use criterion::{criterion_group, criterion_main, Criterion}; -use loro_core::fuzz::test_multi_sites; -use loro_core::fuzz::Action; -use rand::Rng; -use rand::SeedableRng; +#[cfg(feature = "fuzzing")] +mod run { + use super::*; + use arbitrary::Unstructured; + use loro_core::fuzz::test_multi_sites; + use loro_core::fuzz::Action; + use rand::Rng; + use rand::SeedableRng; -pub fn criterion_benchmark(c: &mut Criterion) { - let mut rgn = rand::rngs::StdRng::seed_from_u64(0); - let mut bytes = Vec::new(); - for _ in 0..1000 { - bytes.push(rgn.gen::()); + pub fn criterion_benchmark(c: &mut Criterion) { + let mut rgn = rand::rngs::StdRng::seed_from_u64(0); + let mut bytes = Vec::new(); + for _ in 0..1000 { + bytes.push(rgn.gen::()); + } + + let mut gen = Unstructured::new(&bytes); + let actions = gen.arbitrary::<[Action; 200]>().unwrap(); + c.bench_function("random text edit 2 sites", |b| { + b.iter(|| test_multi_sites(2, actions.clone().into())) + }); } - - let mut gen = Unstructured::new(&bytes); - let actions = gen.arbitrary::<[Action; 200]>().unwrap(); - c.bench_function("random text edit 2 sites", |b| { - b.iter(|| test_multi_sites(2, actions.clone().into())) - }); } +pub fn dumb(_c: &mut Criterion) {} -criterion_group!(benches, criterion_benchmark); +#[cfg(feature = "fuzzing")] +criterion_group!(benches, run::criterion_benchmark); +#[cfg(not(feature = "fuzzing"))] +criterion_group!(benches, dumb); criterion_main!(benches); diff --git a/crates/loro-core/src/isomorph.rs b/crates/loro-core/src/isomorph.rs index 08f80d5f..69a90b59 100644 --- a/crates/loro-core/src/isomorph.rs +++ b/crates/loro-core/src/isomorph.rs @@ -1,3 +1,4 @@ +#![allow(unused)] use std::{ cell::{Ref, RefCell, RefMut}, rc::{Rc, Weak as RcWeak}, diff --git a/crates/loro-core/src/log_store.rs b/crates/loro-core/src/log_store.rs index e2317244..393aeefc 100644 --- a/crates/loro-core/src/log_store.rs +++ b/crates/loro-core/src/log_store.rs @@ -4,7 +4,6 @@ mod iter; use std::{ marker::PhantomPinned, - sync::{Arc, RwLock, Weak}, }; use fxhash::{FxHashMap, FxHashSet}; diff --git a/crates/rle/src/range_map.rs b/crates/rle/src/range_map.rs index 6777dcda..8d3f715c 100644 --- a/crates/rle/src/range_map.rs +++ b/crates/rle/src/range_map.rs @@ -1,5 +1,5 @@ -use bumpalo::boxed::Box as BumpBox; -use std::{cell::UnsafeCell, fmt::Debug, ptr::NonNull}; + +use std::{fmt::Debug, ptr::NonNull}; use fxhash::FxHashSet; @@ -7,8 +7,7 @@ use crate::{ rle_trait::{GlobalIndex, HasIndex, ZeroElement}, rle_tree::{ node::{InternalNode, LeafNode}, - tree_trait::GlobalTreeTrait, - Position, UnsafeCursor, + tree_trait::GlobalTreeTrait, UnsafeCursor, }, HasLength, Mergable, Rle, RleTree, Sliceable, }; diff --git a/crates/rle/src/rle_tree/node/internal_impl.rs b/crates/rle/src/rle_tree/node/internal_impl.rs index f043cb0e..c950e99e 100644 --- a/crates/rle/src/rle_tree/node/internal_impl.rs +++ b/crates/rle/src/rle_tree/node/internal_impl.rs @@ -3,7 +3,7 @@ use std::{ fmt::{Debug, Error, Formatter}, }; -use fxhash::{FxBuildHasher, FxHashSet, FxHasher}; +use fxhash::{FxBuildHasher, FxHashSet}; use smallvec::SmallVec; use crate::rle_tree::{ diff --git a/justfile b/justfile index 587b08a4..c6d4d849 100644 --- a/justfile +++ b/justfile @@ -20,8 +20,8 @@ check: check-unsafe: env RUSTFLAGS="-Funsafe-code --cap-lints=warn" cargo check -fix: - cargo clippy --fix +fix *FLAGS: + cargo clippy --fix {{FLAGS}} deny: cargo deny check