mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
crossbar: check common reasons to not match first
Also, put off the use of EJSON.equals until necessary. Inspired by @hypno2000. See #3697.
This commit is contained in:
@@ -76,6 +76,9 @@
|
||||
(`application-configuration`, `ctl`, `ctl-helper`, `follower-livedata`,
|
||||
`dev-bundle-fetcher`, and `star-translate`).
|
||||
|
||||
* Optimize common cases faced by the "crossbar" data structure (used by oplog
|
||||
tailing and DDP method write tracking). #3697
|
||||
|
||||
* Upgraded dependencies:
|
||||
|
||||
- node: 0.10.36 (from 0.10.33)
|
||||
|
||||
@@ -87,6 +87,26 @@ _.extend(DDPServer._Crossbar.prototype, {
|
||||
// (a targeted write to a collection does not match a targeted query
|
||||
// targeted at a different document)
|
||||
_matches: function (notification, trigger) {
|
||||
// Most notifications that use the crossbar have a string `collection` and
|
||||
// maybe an `id` that is a string or ObjectID. So let's fast-track "nope,
|
||||
// different collection" and "nope, different ID". This makes a noticeable
|
||||
// performance difference; see https://github.com/meteor/meteor/pull/3697
|
||||
if (typeof(notification.collection) === 'string' &&
|
||||
typeof(trigger.collection) === 'string' &&
|
||||
notification.collection !== trigger.collection) {
|
||||
return false;
|
||||
}
|
||||
if (typeof(notification.id) === 'string' &&
|
||||
typeof(trigger.id) === 'string' &&
|
||||
notification.id !== trigger.id) {
|
||||
return false;
|
||||
}
|
||||
if (notification.id instanceof LocalCollection._ObjectID &&
|
||||
trigger.id instanceof LocalCollection._ObjectID &&
|
||||
! notification.id.equals(trigger.id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _.all(trigger, function (triggerValue, key) {
|
||||
return !_.has(notification, key) ||
|
||||
EJSON.equals(triggerValue, notification[key]);
|
||||
|
||||
Reference in New Issue
Block a user