@@ -224,13 +224,11 @@ export class DomRenderer extends Renderer {
224224 rootElementClone = DOM . importIntoDoc ( DOM . content ( protoView . element ) ) ;
225225 elementsWithBindingsDynamic =
226226 DOM . querySelectorAll ( rootElementClone , NG_BINDING_CLASS_SELECTOR ) ;
227- var childNode = DOM . firstChild ( rootElementClone ) ;
228- // TODO(perf): Should be fixed size, since we could pre-compute in in DomProtoView
229- viewRootNodes = [ ] ;
227+ viewRootNodes = ListWrapper . createFixedSize ( protoView . rootNodeCount ) ;
230228 // Note: An explicit loop is the fastest way to convert a DOM array into a JS array!
231- while ( childNode != null ) {
232- ListWrapper . push ( viewRootNodes , childNode ) ;
233- childNode = DOM . nextSibling ( childNode ) ;
229+ var childNode = DOM . firstChild ( rootElementClone ) ;
230+ for ( var i = 0 ; i < protoView . rootNodeCount ; i ++ , childNode = DOM . nextSibling ( childNode ) ) {
231+ viewRootNodes [ i ] = childNode ;
234232 }
235233 } else {
236234 rootElementClone = DOM . importIntoDoc ( protoView . element ) ;
@@ -239,8 +237,9 @@ export class DomRenderer extends Renderer {
239237 }
240238
241239 var binders = protoView . elementBinders ;
242- var boundTextNodes = [ ] ;
240+ var boundTextNodes = ListWrapper . createFixedSize ( protoView . boundTextNodeCount ) ;
243241 var boundElements = ListWrapper . createFixedSize ( binders . length ) ;
242+ var boundTextNodeIdx = 0 ;
244243
245244 for ( var binderIdx = 0 ; binderIdx < binders . length ; binderIdx ++ ) {
246245 var binder = binders [ binderIdx ] ;
@@ -261,7 +260,7 @@ export class DomRenderer extends Renderer {
261260 // boundTextNodes
262261 var textNodeIndices = binder . textNodeIndices ;
263262 for ( var i = 0 ; i < textNodeIndices . length ; i ++ ) {
264- ListWrapper . push ( boundTextNodes , childNodes [ textNodeIndices [ i ] ] ) ;
263+ boundTextNodes [ boundTextNodeIdx ++ ] = childNodes [ textNodeIndices [ i ] ] ;
265264 }
266265
267266 // contentTags
0 commit comments