From 4b896f1494b1ed01e486ec41eb845bf9cd0d96ab Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:19:54 +0000 Subject: [PATCH] refactor(semantic): make `Stats` `Copy` (#5756) `Stats` type is small. Make it `Copy`. --- crates/oxc_semantic/src/builder.rs | 2 +- crates/oxc_semantic/src/stats.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 8feaca355..599a4873f 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -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 diff --git a/crates/oxc_semantic/src/stats.rs b/crates/oxc_semantic/src/stats.rs index aebbf7e4c..e50292d30 100644 --- a/crates/oxc_semantic/src/stats.rs +++ b/crates/oxc_semantic/src/stats.rs @@ -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, @@ -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");