Vivek Modi
08/13/2026, 10:37 PMDatePicker and we use java.util.Calendar in a few date helper functions. These helpers can get called a lot while creating the calendar days, so I was looking at whether it makes sense to reuse the "Calendar" instead of creating a new one each time.
Since Calendar is mutable, I don’t want to use one shared instance. I was thinking about ThreadLocal<Calendar> instead.
Does anyone have a recommendation for this in Compose? Is ThreadLocal reasonable here, or would you keep creating a new Calendar unless we see an actual performance issue?Mark Murphy
08/13/2026, 10:45 PMIsIMHO, no.reasonable here,ThreadLocal
ThreadLocal != "coroutine local".
would you keep creating a newunless we see an actual performance issue?Calendar
Calendar ought to be very cheap to instantiate. Don't create a million instances in a tight loop. Otherwise I would not worry about it unless you see a concrete performance issue.Vivek Modi
08/13/2026, 11:08 PMThreadLocal as well.