perf(orderBy): filters needlessly executed on every digest #16348
Description
I'm submitting a ...
- bug report
- feature request
- other
Current behavior:
from the docs:
When filters are executed
In templates, filters are only executed when their inputs have changed... There are two exceptions to this rule: 1. In general, this applies only to filters that take primitive values as inputs. Filters that receive Objects as input are executed on each $digest, as it would be too costly to track if the inputs have changed...
This effectively means that in all the instances of ng-repeat
that use orderBy
, this filter is rerun on every digest. Instead of "costly" tracking the input array for changes, the framework first sorts this array and then still tracks it. The sorting part here is a pure performance loss which doesn't make any sense.
Expected / new behavior:
Similar to the $stateful
flag, it'd be great to have another flag for filters like orderBy
. This flag will make the filter be executed only if its inputs have changed even if the inputs are objects.
Minimal reproduction of the problem with instructions:
http://jsbin.com/nulonon/edit?html,js,output
AngularJS version: 1.6.x, 1.5.x
Browser: all