ebryn/ember-model — pull request #57 by alexspeller (2013-06-02 00:15:24+00:00)
Title: Speed up bulk loading

So, this is a bit hacky but results in a massive improvement when loading a large array of records.

The problem is that after profiling, it turns out that resolving the promise takes ~1ms. This is problematic as when loading a large array, that's ~1s per thousand records - it also turns out that you don't need the promise stuff when loading the array, as if you need a callback it will be on the record array, not the individual models in the array. No callbacks will be actually called on the individual models, but that's fine because we control the code path that is setting them up, and know that we're not setting any callbacks.

However, the promise still needs to be marked as resolved, because when you then get a record from the identity map, you still need to be able to call `then` on it (which is called immediately as the promise is now marked as resolved).

This change speeds up the loading to ~0.1s per thousand records.