-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Describe the bug
The way ModelUtils._coerce uses coerceArray is inefficient, and is causing it to show up as 20% of my application's CPU usage in profiler runs under a create heavy workload.
The problem code is this in juggler:
try {
// Coerce val into an array if it resembles an array-like object
val = coerceArray(val);
} catch (e) {
// NOOP when not coercable into an array.
}Throwing and catching an error is much more expensive than returning a value, and nearly every call to _coerce hits this try/throw/catch path.
A variant of coerceArray that doesn't throw, but instead returns [arrayVal | undefined, coerced: boolean] I think would fix the performance problem here.
Logs
No response
Additional information
No response
Reproduction
design issue
