Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

perf(injector): cache the results of the native class detection check #14322

Closed
wants to merge 1 commit into from

Conversation

thorn0
Copy link
Contributor

@thorn0 thorn0 commented Mar 26, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Performance improvement

What is the current behavior? (You can also link to an open issue here)

Relatively expensive Function.prototype.toString is called every time a function is checked for being a native class. See #14268.

What is the new behavior (if this is a feature change)?

The results of the check are cached in the $$ngIsClass property of the function.

Does this PR introduce a breaking change?

no

Please check if the PR fulfills these requirements

@lgalfaso
Copy link
Contributor

I would call the property $$ngIsClass just to be sure there is no collision with another library that is also trying to identity if a given function is a class. Otherwise LGTM

@thorn0 thorn0 force-pushed the cache-class-detection-check branch from 4919615 to 86f28a6 Compare March 26, 2016 14:58
@thorn0
Copy link
Contributor Author

thorn0 commented Mar 26, 2016

Done

@lgalfaso
Copy link
Contributor

landed as 5ceb5db

@gkalpak
Copy link
Member

gkalpak commented Mar 26, 2016

@lgalfaso, should we backport this to v1.5.x ?

@lgalfaso
Copy link
Contributor

@gkalpak I lean towards not backporting this, as we are adding a property that may or may not be expected. That said, I would not oppose to this being backported.

@gkalpak
Copy link
Member

gkalpak commented Mar 27, 2016

I don't feel strongly about it either. But if we consider the new property a potential BC, maybe we should mention it as such.

@thorn0
Copy link
Contributor Author

thorn0 commented Mar 30, 2016

Adding this property to a constructor by hand seems to be a way to turn off the deprecated behavior of the bindings even when native classes aren't used. That's something I'd like to do in my projects, so please backport this PR to 1.5. Or probably let's just add an option to $compileProvider for disabling that behavior .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants