Skip to content
Browse files

perf(ivy): share instances of `DomElementSchemaRegistry` (#34332)

To create a binding parser, an instance of `ElementSchemaRegistry` is
required. Prior to this change, each time a new binding parser was
created a new instance of `DomElementSchemaRegistry` would be
instantiated. This is an expensive operation that takes roughly 1ms per
instantiation, so it is key that multiple allocations are avoided.

By sharing a single `DomElementSchemaRegistry`, we avoid two such
allocations, i.e. save ~2ms, per component template.

PR Close #34332
  • Loading branch information
JoostK authored and kara committed Dec 7, 2019
1 parent 45b73c2 commit ce9419220b958bc3d0a419075c22552933e693df
Showing with 3 additions and 2 deletions.
  1. +3 −2 packages/compiler/src/render3/view/template.ts
@@ -2014,13 +2014,14 @@ export function parseTemplate(
return {nodes, styleUrls, styles};

const elementRegistry = new DomElementSchemaRegistry();

* Construct a `BindingParser` with a default configuration.
export function makeBindingParser(
interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG): BindingParser {
return new BindingParser(
new Parser(new Lexer()), interpolationConfig, new DomElementSchemaRegistry(), null, []);
return new BindingParser(new Parser(new Lexer()), interpolationConfig, elementRegistry, null, []);

export function resolveSanitizationFn(context: core.SecurityContext, isAttribute?: boolean) {

0 comments on commit ce94192

Please sign in to comment.
You can’t perform that action at this time.