Skip to content

Commit

Permalink
more reduction of bounds allocations, see #191
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 24, 2019
1 parent f01ca06 commit 263d112
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions js/common/model/Beaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,7 @@ define( function( require ) {
* @public
*/
getBounds: function() {
return this.beakerBounds.setMinMax(
this.positionProperty.value.x - this.width / 2,
this.positionProperty.value.y,
this.positionProperty.value.x + this.width / 2,
this.positionProperty.value.y + this.height
);
return this.compositeBounds;
},

/**
Expand Down
3 changes: 1 addition & 2 deletions js/intro/model/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ define( function( require ) {
* @public
*/
getBounds: function() {
var rect = this.rect;
return new Bounds2( rect.x, rect.y, rect.x + rect.width, rect.y + rect.height );
return this.compositeBounds;
},

/**
Expand Down
1 change: 1 addition & 0 deletions js/intro/model/RectangularThermalMovableModelElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ define( function( require ) {
// @private {Bounds2} - composite bounds for this model element, maintained as position changes
this.compositeBounds = Bounds2.NOTHING.copy();

// update the composite bounds as the model element moves
this.positionProperty.link( function( position ) {
self.compositeBounds.setMinMax(
position.x - width / 2,
Expand Down

0 comments on commit 263d112

Please sign in to comment.