Skip to content

Slow on the try/catch case #24

Open
@joepie91

Description

@joepie91

While profiling an application, I found is-string (and a few related libraries) pretty much topping the charts across the entire codebase:

image

It appears that the try/catch check in tryStringObject does not get optimized (due to being a try/catch, I assume) and this makes the type checks very slow, comparatively speaking. It's on a hot path for me due to being used in argument validation code.

The same problem manifests in is-number-object and is-date-object (and presumably others that happen to not be used in this particular project).

Perhaps this check could be replaced with a faster one in some way, or if not, only applied if the value hits a (faster) test that suggests this check should be applied?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions