mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 04:19:34 +00:00
chore: fix all warnings
This commit is contained in:
parent
23a212e5f6
commit
a90218f229
12 changed files with 39 additions and 34 deletions
|
@ -200,7 +200,7 @@ impl LogStore {
|
|||
let mut container = container.try_lock().unwrap();
|
||||
op.clone()
|
||||
.convert(&mut container, self.cfg.gc.gc)
|
||||
.to_static()
|
||||
.into_static()
|
||||
}
|
||||
|
||||
pub(crate) fn create_container(
|
||||
|
|
|
@ -432,6 +432,7 @@ impl LogStore {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn tailor_changes(&mut self, changes: &mut RemoteClientChanges) {
|
||||
changes.retain(|_, v| !v.is_empty());
|
||||
for (client_id, changes) in changes.iter_mut() {
|
||||
|
|
|
@ -100,7 +100,7 @@ impl<'a> RemoteOp<'a> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn to_static(self) -> RemoteOp<'static> {
|
||||
pub(crate) fn into_static(self) -> RemoteOp<'static> {
|
||||
RemoteOp {
|
||||
counter: self.counter,
|
||||
container: self.container,
|
||||
|
|
|
@ -17,9 +17,9 @@ mod list_state;
|
|||
mod map_state;
|
||||
mod text_state;
|
||||
|
||||
use list_state::ListState;
|
||||
use map_state::MapState;
|
||||
use text_state::TextState;
|
||||
use list_state::List;
|
||||
use map_state::Map;
|
||||
use text_state::Text;
|
||||
|
||||
use super::{arena::SharedArena, oplog::OpLog};
|
||||
|
||||
|
@ -53,9 +53,9 @@ pub trait ContainerState: Clone {
|
|||
#[enum_dispatch(ContainerState)]
|
||||
#[derive(Clone)]
|
||||
pub enum State {
|
||||
ListState,
|
||||
MapState,
|
||||
TextState,
|
||||
List,
|
||||
Map,
|
||||
Text,
|
||||
}
|
||||
|
||||
pub struct ContainerStateDiff {
|
||||
|
@ -126,8 +126,8 @@ impl AppState {
|
|||
|
||||
pub fn create_state(kind: ContainerType) -> State {
|
||||
match kind {
|
||||
ContainerType::Text => State::TextState(TextState::new()),
|
||||
ContainerType::Map => State::MapState(MapState::new()),
|
||||
ContainerType::List => State::ListState(ListState::new()),
|
||||
ContainerType::Text => State::Text(Text::new()),
|
||||
ContainerType::Map => State::Map(Map::new()),
|
||||
ContainerType::List => State::List(List::new()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ use super::ContainerState;
|
|||
|
||||
type ContainerMapping = Arc<Mutex<FxHashMap<ContainerID, ArenaIndex>>>;
|
||||
|
||||
pub struct ListState {
|
||||
list: BTree<List>,
|
||||
pub struct List {
|
||||
list: BTree<ListImpl>,
|
||||
in_txn: bool,
|
||||
undo_stack: Vec<UndoItem>,
|
||||
child_container_to_leaf: Arc<Mutex<FxHashMap<ContainerID, ArenaIndex>>>,
|
||||
}
|
||||
|
||||
impl Clone for ListState {
|
||||
impl Clone for List {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
list: self.list.clone(),
|
||||
|
@ -41,8 +41,8 @@ enum UndoItem {
|
|||
Delete { index: usize, value: LoroValue },
|
||||
}
|
||||
|
||||
struct List;
|
||||
impl BTreeTrait for List {
|
||||
struct ListImpl;
|
||||
impl BTreeTrait for ListImpl {
|
||||
type Elem = LoroValue;
|
||||
|
||||
type Cache = isize;
|
||||
|
@ -89,7 +89,7 @@ impl BTreeTrait for List {
|
|||
}
|
||||
}
|
||||
|
||||
impl UseLengthFinder<List> for List {
|
||||
impl UseLengthFinder<ListImpl> for ListImpl {
|
||||
fn get_len(cache: &isize) -> usize {
|
||||
*cache as usize
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ impl UseLengthFinder<List> for List {
|
|||
}
|
||||
}
|
||||
|
||||
impl ListState {
|
||||
impl List {
|
||||
pub fn new() -> Self {
|
||||
let mut tree = BTree::new();
|
||||
let mapping: ContainerMapping = Arc::new(Mutex::new(Default::default()));
|
||||
|
@ -214,7 +214,7 @@ impl ListState {
|
|||
}
|
||||
}
|
||||
|
||||
impl ContainerState for ListState {
|
||||
impl ContainerState for List {
|
||||
fn apply_diff(&mut self, diff: Diff) {
|
||||
if let Diff::List(delta) = diff {
|
||||
let mut index = 0;
|
||||
|
@ -289,7 +289,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test() {
|
||||
let mut list = ListState::new();
|
||||
let mut list = List::new();
|
||||
fn id(name: &str) -> ContainerID {
|
||||
ContainerID::new_root(name, crate::ContainerType::List)
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ use crate::{
|
|||
use super::ContainerState;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MapState {
|
||||
pub struct Map {
|
||||
map: FxHashMap<InternalString, MapValue>,
|
||||
in_txn: bool,
|
||||
map_when_txn_start: FxHashMap<InternalString, Option<MapValue>>,
|
||||
}
|
||||
|
||||
impl ContainerState for MapState {
|
||||
impl ContainerState for Map {
|
||||
fn apply_diff(&mut self, diff: Diff) {
|
||||
if let Diff::NewMap(delta) = diff {
|
||||
for (key, value) in delta.updated {
|
||||
|
@ -64,7 +64,7 @@ impl ContainerState for MapState {
|
|||
}
|
||||
}
|
||||
|
||||
impl MapState {
|
||||
impl Map {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
map: FxHashMap::default(),
|
||||
|
|
|
@ -11,14 +11,14 @@ use crate::{
|
|||
use super::ContainerState;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TextState {
|
||||
pub struct Text {
|
||||
pub(crate) rope: JumpRope,
|
||||
in_txn: bool,
|
||||
deleted_bytes: Vec<u8>,
|
||||
undo_stack: Vec<UndoItem>,
|
||||
}
|
||||
|
||||
impl Clone for TextState {
|
||||
impl Clone for Text {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
rope: self.rope.clone(),
|
||||
|
@ -41,7 +41,7 @@ enum UndoItem {
|
|||
},
|
||||
}
|
||||
|
||||
impl ContainerState for TextState {
|
||||
impl ContainerState for Text {
|
||||
fn apply_diff(&mut self, diff: Diff) {
|
||||
if let Diff::Text(delta) = diff {
|
||||
let mut index = 0;
|
||||
|
@ -119,7 +119,7 @@ impl ContainerState for TextState {
|
|||
}
|
||||
}
|
||||
|
||||
impl TextState {
|
||||
impl Text {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
rope: JumpRope::new(),
|
||||
|
@ -175,7 +175,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn abort_txn() {
|
||||
let mut state = TextState::new();
|
||||
let mut state = Text::new();
|
||||
state.insert(0, "haha");
|
||||
state.start_txn();
|
||||
state.insert(4, "1234");
|
||||
|
|
|
@ -27,6 +27,7 @@ impl DerefMut for SmString {
|
|||
}
|
||||
|
||||
impl SmString {
|
||||
#[allow(dead_code)]
|
||||
pub fn new() -> Self {
|
||||
SmString(SmartString::new())
|
||||
}
|
||||
|
|
|
@ -930,9 +930,7 @@ impl<'de> serde::de::Visitor<'de> for LoroValueEnumVisitor {
|
|||
}
|
||||
(LoroValueFields::List, v) => v.newtype_variant().map(|x| LoroValue::List(Arc::new(x))),
|
||||
(LoroValueFields::Map, v) => v.newtype_variant().map(|x| LoroValue::Map(Arc::new(x))),
|
||||
(LoroValueFields::Unresolved, v) => {
|
||||
v.newtype_variant().map(|x| LoroValue::Container(x))
|
||||
}
|
||||
(LoroValueFields::Unresolved, v) => v.newtype_variant().map(LoroValue::Container),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> InternalNode<'a, T, A> {
|
|||
|
||||
/// return result need to update cache
|
||||
#[inline]
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn _split(
|
||||
&mut self,
|
||||
) -> (
|
||||
|
@ -421,6 +422,7 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> InternalNode<'a, T, A> {
|
|||
-update
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub(crate) fn apply_updates(
|
||||
&mut self,
|
||||
mut updates: Vec<(usize, A::CacheInParent, Vec<ArenaBoxedNode<'a, T, A>>)>,
|
||||
|
|
|
@ -185,6 +185,7 @@ impl<'bump, T: Rle, A: RleTreeTrait<T>> LeafNode<'bump, T, A> {
|
|||
false
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn insert<F>(
|
||||
&mut self,
|
||||
raw_index: A::Int,
|
||||
|
@ -478,6 +479,7 @@ impl<'bump, T: Rle, A: RleTreeTrait<T>> LeafNode<'bump, T, A> {
|
|||
}
|
||||
|
||||
// TODO: refactor
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub(crate) fn apply_updates<F>(
|
||||
&mut self,
|
||||
mut updates: Vec<(usize, SmallVec<[T; 4]>)>,
|
||||
|
@ -578,6 +580,7 @@ impl<'bump, T: Rle, A: RleTreeTrait<T>> LeafNode<'bump, T, A> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn with_cache_updated(
|
||||
&mut self,
|
||||
result: Result<(), <A::Arena as Arena>::Boxed<'bump, Node<'bump, T, A>>>,
|
||||
|
|
|
@ -625,14 +625,14 @@ where
|
|||
let end = end - index(&vec[0]);
|
||||
let mut ans = Vec::new();
|
||||
let mut index = 0;
|
||||
for i in 0..vec.len() {
|
||||
for item in vec.iter() {
|
||||
if index >= end {
|
||||
break;
|
||||
}
|
||||
|
||||
let len = vec[i].atom_len();
|
||||
let len = item.atom_len();
|
||||
if start < index + len {
|
||||
ans.push(vec[i].slice(start.saturating_sub(index), (end - index).min(len)))
|
||||
ans.push(item.slice(start.saturating_sub(index), (end - index).min(len)))
|
||||
}
|
||||
|
||||
index += len;
|
||||
|
|
Loading…
Reference in a new issue