Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Mar 23, 2024
1 parent 71191c3 commit e4c6f37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/base/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub enum Opcode {

impl Display for Opcode {
#[cfg(not(tarpaulin_include))]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Inst {
}
}

impl fmt::Display for Inst {
impl Display for Inst {
#[cfg(not(tarpaulin_include))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {}", self.opcode, self.operand)
Expand Down
12 changes: 6 additions & 6 deletions src/tvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn get_max_stack_sz() -> usize {

pub fn get_trcobj_sz() -> usize {
static T: OnceLock<usize> = OnceLock::new();
*T.get_or_init(std::mem::size_of::<*mut dyn TrcObj>)
*T.get_or_init(size_of::<*mut dyn TrcObj>)
}

type Byte = u64;
Expand Down Expand Up @@ -86,19 +86,19 @@ impl DynaData {
.byte_offset(self.stack_ptr as isize) as *mut T)
.write(data);
}
self.stack_ptr += std::mem::size_of::<T>();
self.stack_ptr += size_of::<T>();
#[cfg(debug_assertions)]
{
self.type_used
.push((std::any::TypeId::of::<T>(), std::any::type_name::<T>()));
.push((TypeId::of::<T>(), std::any::type_name::<T>()));
}
}

pub fn pop_data<T: Copy + 'static>(&mut self) -> T {
let sz = std::mem::size_of::<T>();
let sz = size_of::<T>();
#[cfg(debug_assertions)]
{
let info = std::any::TypeId::of::<T>();
let info = TypeId::of::<T>();
let info_stack = self.type_used.pop().unwrap();
if info_stack.0 != info {
panic!(
Expand Down Expand Up @@ -178,7 +178,7 @@ impl Context {

/// Load libc
fn load_libc() -> Option<&'static Library> {
static LIBC: std::sync::OnceLock<Option<Library>> = std::sync::OnceLock::new();
static LIBC: OnceLock<Option<Library>> = OnceLock::new();
#[cfg(target_os = "linux")]
{
let tmp = LIBC.get_or_init(|| unsafe {
Expand Down
6 changes: 3 additions & 3 deletions src/tvm/types/data_structure/ac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ impl AcAutomaton {
for i in self.states.first().unwrap().next.values() {
q.push(*i);
}
while q.len() != 0 {
while !q.is_empty() {
let u = q.pop().unwrap();
for (c, val) in &self.states[u].next.clone() {
// 在这里需要向上找到失配指针
// 正常的ac自动机会将剩余的失配部分也指向失配指针
// 但是这个字符集被设计为无限大,可以容纳unicode的ac自动机,所以不能这么做
// 会在匹配时顺着向上找失配指针
self.states[*val].fail = if self.states[self.states[u].fail].next.contains_key(&c) {
self.states[self.states[u].fail].next[&c]
self.states[*val].fail = if self.states[self.states[u].fail].next.contains_key(c) {
self.states[self.states[u].fail].next[c]
} else {
0
};
Expand Down

0 comments on commit e4c6f37

Please sign in to comment.