emberjs/ember.js — pull request #4373 by mixonic (2014-02-15 19:03:39+00:00)
Title: Add count to array computed meta

As discussed with @hjdivad and @mmun this adds the change count to `changeMeta`. I've extracted this from work on `Ember.computed.slice` which is waiting for some feedback before I can PR it. This can probably help with performance on `Ember.computed.sort` out of the box.

```
Ember.computed.sort = function(itemsKey, begin, end) {

var changsInBatch = 0;

return Ember.arrayComputed(itemsKey, {
/* ... */
removedItem: function (array, item, changeMeta, instanceMeta) {
if (changesInBatch > 1) {
changesInBatch--;
} else {
changesInBatch = changeMeta.changeCount;
}
// changesInBatch is how many operations remain (including the current one)
}
});
};
```

Maybe this work should just go straight into a patch for `sort`? I wanted to get it out there regardless.