Parse `attrs` before comparing to `attachment.attributes`. Small efficiency gain.

Props garyc40. Fixes #24753.

git-svn-id: https://develop.svn.wordpress.org/trunk@24800 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2013-07-27 07:09:05 +00:00
parent 1fd6c87716
commit 9d2e982a79
1 changed files with 7 additions and 5 deletions

View File

@ -401,7 +401,6 @@ window.wp = window.wp || {};
attachments.on( 'add change remove', this._validateHandler, this );
attachments.on( 'reset', this._validateAllHandler, this );
this.validateAll( attachments );
return this;
},
@ -487,7 +486,8 @@ window.wp = window.wp || {};
resp = [resp];
return _.map( resp, function( attrs ) {
var id, attachment;
var id, attachment, newAttributes;
if ( attrs instanceof Backbone.Model ) {
id = attrs.get( 'id' );
attrs = attrs.attributes;
@ -495,9 +495,11 @@ window.wp = window.wp || {};
id = attrs.id;
}
attachment = Attachment.get( attrs.id );
if ( ! _.isEqual( attachment.attributes, attrs ) )
attachment.set( attachment.parse( attrs, xhr ) );
attachment = Attachment.get( id );
newAttributes = attachment.parse( attrs, xhr );
if ( ! _.isEqual( attachment.attributes, newAttributes ) )
attachment.set( newAttributes );
return attachment;
});