Skip to content

Commit

Permalink
perf: reduce unnecessary clone
Browse files Browse the repository at this point in the history
  • Loading branch information
junyu0312 committed Nov 4, 2023
1 parent 3618fa3 commit 237970b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/zkwasm/src/circuits/utils/table_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@ pub struct MemoryRWEntry {
}

#[derive(Debug)]
pub struct EventTableEntryWithMemoryInfo {
pub eentry: EventTableEntry,
pub struct EventTableEntryWithMemoryInfo<'a> {
pub eentry: &'a EventTableEntry,
pub memory_rw_entires: Vec<MemoryRWEntry>,
}

#[derive(Debug)]
pub(crate) struct EventTableWithMemoryInfo(
pub(in crate::circuits) Vec<EventTableEntryWithMemoryInfo>,
pub(crate) struct EventTableWithMemoryInfo<'a>(
pub(in crate::circuits) Vec<EventTableEntryWithMemoryInfo<'a>>,
);

impl EventTableWithMemoryInfo {
impl<'a> EventTableWithMemoryInfo<'a> {
pub(in crate::circuits) fn new(
event_table: &EventTable,
event_table: &'a EventTable,
memory_writing_table: &MemoryWritingTable,
) -> Self {
let lookup = memory_writing_table.build_lookup_mapping();
Expand All @@ -140,6 +140,7 @@ impl EventTableWithMemoryInfo {
.unwrap();
records[idx]
} else {
println!("lookup eid: {}", eid);
let idx = records
.binary_search_by(|(start_eid, end_eid)| {
if eid <= start_eid {
Expand All @@ -160,7 +161,7 @@ impl EventTableWithMemoryInfo {
.entries()
.iter()
.map(|eentry| EventTableEntryWithMemoryInfo {
eentry: eentry.clone(),
eentry: &eentry,
memory_rw_entires: memory_event_of_step(eentry, &mut 1)
.iter()
.map(|mentry| {
Expand Down

0 comments on commit 237970b

Please sign in to comment.