#38Implement inlining for small functions

  • avatar~lino-levancommented · 2 years ago
    Author

    Repro:

    fn x() {
      let print = @js("console").log;
      print("Hello, World!");
    }
    
    x();
    

    Result:

    // Language Compiler v0.1.3. Alpha quality software.
    let x = () => {
    console.log("Hello, World!");
    return undefined;
    };
    x();
    

    Should be:

    // Language Compiler v0.1.3. Alpha quality software.
    console.log("Hello, World!");
    

    Milestone: later.

  • avatar~lino-levan changed the status to Todo · 2 years ago
  • avatar~lino-levancommented · 2 years ago
    Author

    I think there's a few times where you want to inline a function:

    • If it's only ever used once, inline it.
    • If it's used a few times and it's short, inline it
    • If it's really short (1-2 lines maybe), always inline it