Remix.run Logo
hyperionultra 12 hours ago

~3% performance gains. I didn’t understood part about $this.

rererereferred 11 hours ago | parent | next [-]

If the closure doesn't use $this (an instance of the current class) then it doesn't need to store a reference to it, which also skips the bookkeeping from the garbage collector.

ethan_smith 6 hours ago | parent | prev [-]

In PHP, closures defined inside a class method automatically capture `$this`, which means the closure holds a reference to the entire object even if it never uses it. This prevents the object from being garbage collected and adds overhead. The optimization detects when `$this` isn't actually used and makes the closure static automatically, dropping that unnecessary reference.