This greatly reduces the number of places in the code where "stringified
IDs" are passed around.
Specifically, changed these maps into _IdMaps:
- minimongo
- the main LocalCollection docs map
- LocalCollection._savedOriginals
- unordered query results, in several places:
- query.results
- query.results_snapshot
- return value from _getRawObjects
- as passed to _diffQueryChanges
- livedata
- Connection._serverDocuments[collection]
- mongo-livedata
- SynchronousCursor._visitedIds
- return value from SynchronousCursor.getRawObjects
- PollingObserveDriver._results (when unordered)
Specifically, factor out the logic that keeps a cache of the current
cursor contents from the part that calls observe callbacks.
Also:
- move IdMap from mongo-livedata to minimongo
- get rid of references to the 'moved' callback which no longer exists
Unordered observations have no moved callback and don't pass indices to the
other callbacks. This is used for the automatic cursor publication (because DDP
collections are not ordered) and for Cursor.count(). Internally, the results of
unordered observations are stored as objects instead of an array. This change
has no publicly observable changes, but should increase performance, especially
server-side (since the _diffQuery that drives DDP subscription updates no longer
needs the full complexity of the ordered move detector).
Also, minor optimization to LocalCollection.Cursor._getRawObjects where the
selector is a single ID that is not in the collection (now O(1) instead of
O(n)).