udem-dlteam / pnut

🥜 A Self-Compiling C Transpiler Targeting Human-Readable POSIX Shell
https://pnut.sh
BSD 2-Clause "Simplified" License
425 stars 14 forks source link

Reuse temporary identifiers used for nested function calls #78

Closed laurenthuberdeau closed 2 months ago

laurenthuberdeau commented 2 months ago

Context

Before, f(g(x)) used 2 temporary variables:

t1 = g(x)
t2 = f(t1)

But really, we can reuse the same temporary:

t1 = g(x)
t1 = f(t1)

This reduces the number of temporary variables used, which slightly increases performance.