@@ -529,6 +529,7 @@ function $RootScopeProvider(){
529
529
oldValue . length = oldLength = newLength ;
530
530
}
531
531
// copy the items to oldValue and look for changes.
532
+ // TODO(perf): consider caching oldValue[i] and newValue[i]
532
533
for ( var i = 0 ; i < newLength ; i ++ ) {
533
534
bothNaN = ( oldValue [ i ] !== oldValue [ i ] ) &&
534
535
( newValue [ i ] !== newValue [ i ] ) ;
@@ -540,6 +541,7 @@ function $RootScopeProvider(){
540
541
} else {
541
542
if ( oldValue !== internalObject ) {
542
543
// we are transitioning from something which was not an object into object.
544
+ // TODO(perf): Object.create(null) + don't use hasOwnProperty for oldValue
543
545
oldValue = internalObject = { } ;
544
546
oldLength = 0 ;
545
547
changeDetected ++ ;
@@ -700,7 +702,10 @@ function $RootScopeProvider(){
700
702
watch = watchers [ length ] ;
701
703
// Most common watches are on primitives, in which case we can short
702
704
// circuit it with === operator, only when === fails do we use .equals
705
+ // TODO(perf): is this if needed?
703
706
if ( watch ) {
707
+ // TODO(perf): the last typeof number + NaN checks are executed for all counter watches
708
+ // can we skip it or at least remember if the lastValue is NaN
704
709
if ( ( value = watch . get ( current ) ) !== ( last = watch . last ) &&
705
710
! ( watch . eq
706
711
? equals ( value , last )
@@ -709,6 +714,7 @@ function $RootScopeProvider(){
709
714
dirty = true ;
710
715
lastDirtyWatch = watch ;
711
716
watch . last = watch . eq ? copy ( value , null ) : value ;
717
+ // TODO(perf): initialize all watches via async queue?
712
718
watch . fn ( value , ( ( last === initWatchVal ) ? value : last ) , current ) ;
713
719
if ( ttl < 5 ) {
714
720
logIdx = 4 - ttl ;
@@ -811,6 +817,7 @@ function $RootScopeProvider(){
811
817
this . $$destroyed = true ;
812
818
if ( this === $rootScope ) return ;
813
819
820
+ // TODO(perf): $$listenerCount should be Object.create(null), then use `for in`
814
821
forEach ( this . $$listenerCount , bind ( null , decrementListenerCount , this ) ) ;
815
822
816
823
// sever all the references to parent scopes (after this cleanup, the current scope should
0 commit comments