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`.
This commit is contained in:
overlookmotel 2024-10-23 13:26:24 +00:00
parent 57685b28e8
commit e5f4b4a333

View file

@ -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);