From edf83adbc3ad7a7ce8d8be3ea42ce5fb5abc513c Mon Sep 17 00:00:00 2001 From: Phil Freo Date: Thu, 13 Dec 2012 18:05:52 -0500 Subject: [PATCH] Removing calls to Collection#getByCid (it's taken care of in Collection#get now) --- backbone-relational.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backbone-relational.js b/backbone-relational.js index 62f97703..a998461e 100755 --- a/backbone-relational.js +++ b/backbone-relational.js @@ -862,7 +862,7 @@ model = this.relatedModel.findOrCreate( item, { create: this.options.createModels } ); } - if ( model && !this.related.getByCid( model ) && !this.related.get( model ) ) { + if ( model && !this.related.get( model ) ) { models.push( model ); } }, this ); @@ -936,7 +936,7 @@ tryAddRelated: function( model, options ) { options = this.sanitizeOptions( options ); - if ( !this.related.getByCid( model ) && !this.related.get( model ) ) { + if ( !this.related.get( model ) ) { // Check if this new model was specified in 'this.keyContents' var item = _.any( this.keyContents || [], function( item ) { var id = Backbone.Relational.store.resolveIdForItem( this.relatedModel, item ); @@ -1009,7 +1009,7 @@ var dit = this; options = this.unsanitizeOptions( options ); model.queue( function() { // Queued to avoid errors for adding 'model' to the 'this.related' set twice - if ( dit.related && !dit.related.getByCid( model ) && !dit.related.get( model ) ) { + if ( dit.related && !dit.related.get( model ) ) { dit.related.add( model, options ); } }); @@ -1017,7 +1017,7 @@ removeRelated: function( model, options ) { options = this.unsanitizeOptions( options ); - if ( this.related.getByCid( model ) || this.related.get( model ) ) { + if ( this.related.get( model ) ) { this.related.remove( model, options ); } } @@ -1599,10 +1599,10 @@ model = Backbone.Collection.prototype._prepareModel.call( this, model, options ); } - if ( model instanceof Backbone.Model && !this.get( model ) && !this.getByCid( model ) ) { - modelsToAdd.push( model ); - } - }, this ); + if ( model instanceof Backbone.Model && !this.get( model ) ) { + modelsToAdd.push( model ); + } + }, this ); // Add 'models' in a single batch, so the original add will only be called once (and thus 'sort', etc). if ( modelsToAdd.length ) {