Repository: swc-project/swc
File: crates/swc_ecma_minifier/src/compress/optimize/inline.rs (Rust)

Code before:
                            || usage
                                .flags
                                .contains(VarUsageInfoFlags::EXECUTED_MULTIPLE_TIME)
                            || usage.flags.contains(VarUsageInfoFlags::USED_AS_ARG)
                                && ref_count > 1
                            || ref_count > usage.callee_count
                            || !is_arrow_simple_enough_for_copy(arr).is_some_and(|cost| cost <= 8))
                    }
                    _ => false,
                }
            {
                if !inlined_into_init {
                    inlined_into_init = true;
                    self.vars.inline_with_multi_replacer(init);
                }

                self.mode.store(id.clone(), &*init);

                let VarUsageInfo {
                    usage_count,
                    property_mutation_count,
                    flags,
                    ..
                } = **usage;
                let mut inc_usage = || {
                    println!("{init:?}");
                    if let Some(i) = match &*init {
                        // The condition above filters `init` for literals, idents, and arrow
                        // functions.
                        Expr::Ident(i) => Some(i),
                        Expr::Arrow(arr) => match &*arr.body {
                            BlockStmtOrExpr::Expr(e) => match &**e {
                                Expr::Call(i) => i.callee.as_expr().and_then(|e| e.as_ident()),
                                _ => None,
                            },
                            BlockStmtOrExpr::BlockStmt(BlockStmt { stmts, .. }) => {
                                if let &[Stmt::Return(ReturnStmt { arg: Some(arg), .. })] =
                                    &&**stmts
                                {
                                    match &**arg {
                                        Expr::Call(i) => {
                                            i.callee.as_expr().and_then(|e| e.as_ident())
                                        }
                                        _ => None,
                                    }
                                } else {
                                    None
                                }
                            }
                        },
                        _ => None,

Review comment (bug):
Debug print statement should be removed before merging to production. This appears to be leftover debugging code.
```suggestion

```

Code after:
                            || usage
                                .flags
                                .contains(VarUsageInfoFlags::EXECUTED_MULTIPLE_TIME)
                            || usage.flags.contains(VarUsageInfoFlags::USED_AS_ARG)
                                && ref_count > 1
                            || ref_count > usage.callee_count
                            || !is_arrow_simple_enough_for_copy(arr).is_some_and(|cost| cost <= 8))
                    }
                    _ => false,
                }
            {
                if !inlined_into_init {
                    inlined_into_init = true;
                    self.vars.inline_with_multi_replacer(init);
                }

                self.mode.store(id.clone(), &*init);

                let VarUsageInfo {
                    usage_count,
                    property_mutation_count,
                    flags,
                    ..
                } = **usage;
                let mut inc_usage = || {
                    if let Some(i) = match &*init {
                        // The condition above filters `init` for literals, idents, and arrow
                        // functions.
                        Expr::Ident(i) => Some(i),
                        Expr::Arrow(arr) => match &*arr.body {
                            BlockStmtOrExpr::Expr(e) => match &**e {
                                Expr::Call(i) => i.callee.as_expr().and_then(|e| e.as_ident()),
                                _ => None,
                            },
                            BlockStmtOrExpr::BlockStmt(BlockStmt { stmts, .. }) => {
                                if let &[Stmt::Return(ReturnStmt { arg: Some(arg), .. })] =
                                    &&**stmts
                                {
                                    match &**arg {
                                        Expr::Call(i) => {
                                            i.callee.as_expr().and_then(|e| e.as_ident())
                                        }
                                        _ => None,
                                    }
                                } else {
                                    None
                                }
                            }
                        },
                        _ => None,
                    } {