Project

Profile

Help

Bug #3555

closed

Performance of "castable"

Added by Michael Kay over 6 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2017-12-04
Due date:
% Done:

0%

Estimated time:
Applies to JS Branch:
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

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 })
Actions #1

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