Skip to content

Commit

Permalink
refactor(transformer): RegExp transform reuse var (#5527)
Browse files Browse the repository at this point in the history
Nit. Use local `flags` var instead of `regexp.regex.flags`.
  • Loading branch information
overlookmotel committed Sep 6, 2024
1 parent 9b7ecc7 commit 758a10c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/oxc_transformer/src/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ impl<'a> Traverse<'a> for RegExp<'a> {
ctx.ast.argument_expression(ctx.ast.expression_string_literal(SPAN, pattern_source)),
);

let flags = regexp.regex.flags.to_string();
let flags = ctx.ast.argument_expression(ctx.ast.expression_string_literal(SPAN, flags));
arguments.push(flags);
let flags_str = flags.to_string();
let flags_str =
ctx.ast.argument_expression(ctx.ast.expression_string_literal(SPAN, flags_str));
arguments.push(flags_str);

*expr = ctx.ast.expression_new(
regexp.span,
Expand Down

0 comments on commit 758a10c

Please sign in to comment.