JS question, cross linking it here since the #javascript channel is mostly dead. https://clojurians.slack.com/archives/C061V0G8Z/p1756134459403209
An LLM has been answering my question in #javascript 😨 https://clojurians.slack.com/archives/C061V0G8Z/p1756134459403209
I'd suspect that this is due to f being reassigned and changing "shape" or whatever JS calls this
see if adding x = f.deref(); and calling x instead makes any difference
Fun fact from Firefox: wrapping the first two in functions, using const and let where appropriate, and calling those functions resulted in the expected behavior - the second run is faster.
=> f1()
87
=> f2()
65yes @thheller if I rename the assigned variable to f2 it's equally fast.
FWIW I did the experiment without any renamings, it's still f = f.deref().
thanks. it looks like a var deref indirection isn't causing much extra work it seems, even if the function itself isn't doing much
I'd suspect that the deref is highly dependent on what it derefs. if its only ever assigned once and of the same "type" then its basically JIT'd out. if not I'd suspect a slowdown.
always be wary of these kinds of microbenchmarks. too easy to reach for conclusions too fast 😛
true