3 ms·
I would expect the relevant optimization to be inlining and/or specialization. An inlined function could allow the JIT detect that the hot path creates and de
by amluto 2y ago
I would expect the relevant optimization to be inlining and/or specialization. An inlined function could allow the JIT detect that the hot path creates and destroys an object without ever using it. Alternatively, if the JIT could specialize the callee for the specific function that is passed in, then the overhead would go away.
(One think I like about less heavily JIT-reliant languages is that it can be more obvious when something will incur a runtime cost.)
- vips7L 2y agoReading more about how invokedynamic works, it appears that if your lambda doesn't capture it shouldn't allocate it more than one time.