perf(ivy): use instanceof operator to check for NodeInjectorFactory instances (#33082)

We used to have a custom version of the NodeInjectorFactory check that was
supposed to be faster to the direct usage of the `instanceof` operator. This
might have been the case in the past but the recent benchmark shows that using
`instanceof` speeds up the `directive_instantiate` by ~10%
(from time getting from ~340ms down to ~305ms).

PR Close #33082
This commit is contained in:
Pawel Kozlowski 2019-10-10 16:08:26 +02:00 committed by Miško Hevery
parent 22d4efbed1
commit 8d111da7f6
1 changed files with 1 additions and 3 deletions

View File

@ -242,9 +242,7 @@ export class NodeInjectorFactory {
} }
export function isFactory(obj: any): obj is NodeInjectorFactory { export function isFactory(obj: any): obj is NodeInjectorFactory {
// See: https://jsperf.com/instanceof-vs-getprototypeof return obj instanceof NodeInjectorFactory;
return obj !== null && typeof obj == 'object' &&
Object.getPrototypeOf(obj) == NodeInjectorFactory.prototype;
} }
// Note: This hack is necessary so we don't erroneously get a circular dependency // Note: This hack is necessary so we don't erroneously get a circular dependency