Skip to content

Commit

Permalink
Replace delete in favor of setting to undefined to prevent V8 deoptim…
Browse files Browse the repository at this point in the history
…ization.
  • Loading branch information
lehni committed Jan 5, 2014
1 parent 2973fef commit 6ad2105
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
project = this._project;
if (flags & /*#=*/ ChangeFlag.GEOMETRY) {
// Clear cached bounds and position whenever geometry changes
delete this._bounds;
delete this._position;
delete this._decomposed;
delete this._globalMatrix;
this._bounds = this._position = this._decomposed =
this._globalMatrix = undefined;
}
if (cacheParent && (flags
& (/*#=*/ ChangeFlag.GEOMETRY | /*#=*/ ChangeFlag.STROKE))) {
Expand Down Expand Up @@ -814,7 +812,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
setPivot: function(/* point */) {
this._pivot = Point.read(arguments);
// No need for _changed() since the only thing this affects is _position
delete this._position;
this._position = undefined;
},

_pivot: null,
Expand Down Expand Up @@ -999,16 +997,15 @@ var Item = Base.extend(Callback, /** @lends Item# */{
for (var i = 0, list = item._boundsCache.list, l = list.length;
i < l; i++) {
var child = list[i];
delete child._bounds;
child._bounds = child._position = undefined;
// Delete position as well, since it's depending on bounds.
delete child._position;
// We need to recursively call _clearBoundsCache, because if
// the cache for this child's children is not valid anymore,
// that propagates up the DOM tree.
if (child !== item && child._boundsCache)
child._clearBoundsCache();
}
delete item._boundsCache;
item._boundsCache = undefined;
}
}
}
Expand Down

0 comments on commit 6ad2105

Please sign in to comment.