Bug #3555
closedPerformance of "castable"
0%
Description
The "castable as" operator is implemented essentially as
try { targetType.cast(input); return true } catch { return false };
Throwing and catching exceptions is expensive and this shows up in performance profiles.
An alternative would be for Atomic.cast() functions to accept an optional second argument onError whose value is a function that is called if casting is not possible; this needs to be passed through to functions such as fromString() and fromDouble() that do the cast, and thence to the two functions invalidValue() and disallowedCast() which actually throw the error. The implementation of "castable" could then be changed to:
var result = true; targetType.cast(input, function(){ result = false })
Updated by Michael Kay almost 4 years ago
- Description updated (diff)
- Status changed from New to Closed
Closing this down as we have no concrete evidence this is causing any problems.
Please register to edit this issue
Also available in: Atom PDF Tracking page