Make WordPress Core

Changeset 24800


Ignore:
Timestamp:
07/27/2013 07:09:05 AM (12 years ago)
Author:
markjaquith
Message:

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

Props garyc40. Fixes #24753.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/media-models.js

    r24771 r24800  
    402402            attachments.on( 'add change remove', this._validateHandler, this );
    403403            attachments.on( 'reset', this._validateAllHandler, this );
    404 
    405404            this.validateAll( attachments );
    406405            return this;
     
    488487
    489488            return _.map( resp, function( attrs ) {
    490                 var id, attachment;
     489                var id, attachment, newAttributes;
     490
    491491                if ( attrs instanceof Backbone.Model ) {
    492492                    id = attrs.get( 'id' );
     
    496496                }
    497497
    498                 attachment = Attachment.get( attrs.id );
    499                 if ( ! _.isEqual( attachment.attributes, attrs ) )
    500                     attachment.set( attachment.parse( attrs, xhr ) );
     498                attachment = Attachment.get( id );
     499                newAttributes = attachment.parse( attrs, xhr );
     500
     501                if ( ! _.isEqual( attachment.attributes, newAttributes ) )
     502                    attachment.set( newAttributes );
    501503
    502504                return attachment;
Note: See TracChangeset for help on using the changeset viewer.