Skip to content

Commit

Permalink
perf(ivy): speed up ngcc ivy switch processing (#25534)
Browse files Browse the repository at this point in the history
Only parse the AST for ngcc ivy switch constants
if the marker is not found in the module text.

PR Close #25534
  • Loading branch information
petebacondarwin authored and mhevery committed Aug 31, 2018
1 parent e964319 commit 20b9c61
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/compiler-cli/src/ngcc/src/host/fesm2015_host.ts
Expand Up @@ -12,7 +12,7 @@ import {ClassMember, ClassMemberKind, CtorParameter, Decorator} from '../../../n
import {TypeScriptReflectionHost, reflectObjectLiteral} from '../../../ngtsc/metadata';
import {findAll, getNameText} from '../utils';

import {NgccReflectionHost, SwitchableVariableDeclaration, isSwitchableVariableDeclaration} from './ngcc_host';
import {NgccReflectionHost, PRE_NGCC_MARKER, SwitchableVariableDeclaration, isSwitchableVariableDeclaration} from './ngcc_host';

export const DECORATORS = 'decorators' as ts.__String;
export const PROP_DECORATORS = 'propDecorators' as ts.__String;
Expand Down Expand Up @@ -205,7 +205,10 @@ export class Fesm2015ReflectionHost extends TypeScriptReflectionHost implements
* @returns An array of variable declarations that match.
*/
getSwitchableDeclarations(module: ts.Node): SwitchableVariableDeclaration[] {
return findAll(module, isSwitchableVariableDeclaration);
// Don't bother to walk the AST if the marker is not found in the text
return module.getText().indexOf(PRE_NGCC_MARKER) >= 0 ?
findAll(module, isSwitchableVariableDeclaration) :
[];
}

/**
Expand Down

0 comments on commit 20b9c61

Please sign in to comment.