ScopedValue polyfill follow-up
Andrew Haley
aph-open at littlepinkcloud.com
Mon Feb 10 10:26:35 UTC 2025
On 2/9/25 11:58, Davor Hrg wrote:
> My concern may be misguided, but I do want to ask if there is any overhead to worry about with creating a lambda to create a scope,
>
> runWhere(CTX, value,()->{
> //do something
> });
It's probably not a big deal, but you really don't have to create a lambda
every time you use a scoped value. runWhere() takes a Runnable, and you can
create a Runnable ahead of time, and re-use it.
Also, any lambda you create at the call site is potentially scalar replaced
anyway, as a common HotSpot optimization.
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the loom-dev
mailing list