Rename methods

This commit is contained in:
micialware committed 2026-08-30 19:22:28 +03:00
1 parent b006ece0c1
commit 3ac7cd068b
3 files changed
+125 -86

No files matched your search

+11 -12
View File
@@ -1,4 +1,3 @@
use std::cmp::Ordering;
use crate::app::AppState;
use crate::core::srs::{FADE_PER_DAY, MAX_SCORE, OrderMode, WordOpenMode};
use crate::data::{INVALID_ID, Id};
@@ -7,6 +6,7 @@ use chrono::{DateTime, Utc};
use log::info;
use rayon::prelude::*;
use rhai::{Engine, Scope};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::marker::PhantomData;
use std::time::Instant;
@@ -184,24 +184,23 @@ pub struct EntityHandle<E> {
pub(crate) id: Id,
index: i32,
pub(crate) _phantom: PhantomData<E>,
}
impl<T> Clone for EntityHandle<T> {
fn clone(&self) -> Self {
EntityHandle{
EntityHandle {
id: self.id,
index: self.index,
_phantom: Default::default(),
}
}
}
impl<T> EntityHandle<T> {
impl<T> EntityHandle<T> {
pub fn new(id: Id, index: usize, real: bool) -> Self {
Self {
id,
index : index as i32 | (!real as i32) << 31,
_phantom: Default::default()
index: index as i32 | (!real as i32) << 31,
_phantom: Default::default(),
}
}
pub fn index(&self) -> usize {
@@ -236,18 +235,18 @@ impl<T> PartialOrd<Self> for EntityHandle<T> {
impl<T> Ord for EntityHandle<T> {
fn cmp(&self, other: &Self) -> Ordering {
if self.real() && !other.real() {
return Ordering::Less
return Ordering::Less;
}
if !self.real() && other.real(){
return Ordering::Greater
if !self.real() && other.real() {
return Ordering::Greater;
}
self.id.cmp(&other.id)
}
}
pub trait EntityData{
pub trait EntityData {
fn id(&self) -> Id;
fn set_id(&mut self, id: Id);
}
+5 -5
View File
@@ -98,7 +98,7 @@ where
rule: Box<dyn Fn(&T) -> bool + Send + Sync>,
parallel: bool,
_marker: PhantomData<(R, D)>,
shift_stamp: u16
shift_stamp: u16,
}
impl<T: EntityData + Clone, R: Repository<T, D>, D: DbLayer<T>> Query<T, R, D> {
@@ -177,8 +177,8 @@ pub trait BatchedDbLayer<T>
where
T: EntityData,
{
fn delete_many(&mut self, ids: &[Id], connection: &Connection) -> MaybeError;
fn add_many_entity(&mut self, entity: &mut [T], connection: &Connection) -> MaybeError;
fn delete_many_entities(&mut self, ids: &[Id], connection: &Connection) -> MaybeError;
fn add_many_entities(&mut self, entity: &mut [T], connection: &Connection) -> MaybeError;
}
#[derive(Clone)]
@@ -405,7 +405,7 @@ impl<T: EntityData + Clone, D: BatchedDbLayer<T> + DbLayer<T>> BatchedRepository
});
self.data_layer
.add_many_entity(&mut temp_values, &self.connection.read())?;
.add_many_entities(&mut temp_values, &self.connection.read())?;
let start = self.cache.len();
@@ -447,7 +447,7 @@ impl<T: EntityData + Clone, D: BatchedDbLayer<T> + DbLayer<T>> BatchedRepository
!remove
});
self.data_layer
.delete_many(cached.as_slice(), &self.connection.read())?;
.delete_many_entities(cached.as_slice(), &self.connection.read())?;
let len = cached.len();
cell = 0;
self.cache.retain(|x| {