Skip to content

Commit

Permalink
perf(ivy): speed up ngcc ivy switch processing
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.
  • Loading branch information
petebacondarwin committed Aug 28, 2018
1 parent a5f679f commit 29457cc
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 29457cc

Please sign in to comment.