Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(semantic): make Stats Copy #5756

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor(semantic): make Stats Copy (#5756)
`Stats` type is small. Make it `Copy`.
  • Loading branch information
overlookmotel committed Sep 13, 2024
commit 4b896f1494b1ed01e486ec41eb845bf9cd0d96ab
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'a> SemanticBuilder<'a> {
self.symbols.len() as u32,
self.symbols.references.len() as u32,
);
Stats::assert_accurate(&actual_stats, &stats);
Stats::assert_accurate(actual_stats, stats);
}

// Checking syntax error on module record requires scope information from the previous AST pass
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_semantic/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use oxc_syntax::scope::{ScopeFlags, ScopeId};
///
/// [`Semantic`]: super::Semantic
/// [`Semantic::stats`]: super::Semantic::stats
#[derive(Default, Debug)]
#[derive(Clone, Copy, Default, Debug)]
pub struct Stats {
pub nodes: u32,
pub scopes: u32,
Expand Down Expand Up @@ -70,7 +70,7 @@ impl Stats {
///
/// # Panics
/// Panics if stats are not accurate.
pub fn assert_accurate(actual: &Self, estimated: &Self) {
pub fn assert_accurate(actual: Self, estimated: Self) {
assert_eq!(actual.nodes, estimated.nodes, "nodes count mismatch");
assert_eq!(actual.scopes, estimated.scopes, "scopes count mismatch");
assert_eq!(actual.references, estimated.references, "references count mismatch");
Expand Down