From e5f4b4a333eaa2fb8fa2629f86f464e94883bd8f Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:26:24 +0000 Subject: [PATCH] refactor(transformer/react-refresh): dereference `ScopeId` as soon as possible (#6820) Style nit. Dereference `&ScopeId` to `ScopeId` as early as possible. `&ScopeId` is 8 bytes, whereas `ScopeId` is 4 bytes. In simple cases like this, compiler will optimize it anyway, but still I think it's a better pattern to dererence early. In more complicated cases, it will be better for performance, and in my opinion, it makes things clearer if vars called `scope_id` are always a `ScopeId`, not sometimes a `&ScopeId`. --- crates/oxc_transformer/src/react/refresh.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_transformer/src/react/refresh.rs b/crates/oxc_transformer/src/react/refresh.rs index 2935843e7..67547b609 100644 --- a/crates/oxc_transformer/src/react/refresh.rs +++ b/crates/oxc_transformer/src/react/refresh.rs @@ -646,7 +646,7 @@ impl<'a, 'ctx> ReactRefresh<'a, 'ctx> { let target_scope_id = ctx .scopes() .ancestors(ctx.current_scope_id()) - .find(|scope_id| ctx.scopes().get_flags(*scope_id).is_var()) + .find(|&scope_id| ctx.scopes().get_flags(scope_id).is_var()) .unwrap_or_else(|| ctx.current_scope_id()); let binding = ctx.generate_uid("s", target_scope_id, SymbolFlags::FunctionScopedVariable);