mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
We can directly access Item#_id.
No need to call Item#getId() internally.
This commit is contained in:
parent
cb8c94ef7e
commit
cadc2e78ca
3 changed files with 19 additions and 22 deletions
|
@ -1294,23 +1294,20 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
|||
// times the same structure.
|
||||
// Note: This needs to happen before returning cached values, since even
|
||||
// then, _boundsCache needs to be kept up-to-date.
|
||||
if (cacheItem) {
|
||||
if (this._parent) {
|
||||
// Set-up the parent's boundsCache structure if it does not
|
||||
// exist yet and add the cacheItem to it.
|
||||
var ref = this._parent._boundsCache
|
||||
= this._parent._boundsCache || {
|
||||
// Use both a hashtable for ids and an array for the list,
|
||||
// so we can keep track of items that were added already
|
||||
ids: {},
|
||||
list: []
|
||||
};
|
||||
var id = cacheItem.getId();
|
||||
// Only add the item if it isn't there already
|
||||
if (!ref.ids[id]) {
|
||||
ref.list.push(cacheItem);
|
||||
ref.ids[id] = cacheItem;
|
||||
}
|
||||
if (cacheItem && this._parent) {
|
||||
// Set-up the parent's boundsCache structure if it does not
|
||||
// exist yet and add the cacheItem to it.
|
||||
var id = cacheItem._id,
|
||||
ref = this._parent._boundsCache
|
||||
= this._parent._boundsCache || {
|
||||
// Use both a hashtable for ids and an array for the list,
|
||||
// so we can keep track of items that were added already
|
||||
ids: {},
|
||||
list: []
|
||||
};
|
||||
if (!ref.ids[id]) {
|
||||
ref.list.push(cacheItem);
|
||||
ref.ids[id] = cacheItem;
|
||||
}
|
||||
}
|
||||
if (cache && this._bounds && this._bounds[cache])
|
||||
|
@ -2125,7 +2122,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
|||
var key = 'mouse' + name,
|
||||
sets = Tool._removeSets = Tool._removeSets || {};
|
||||
sets[key] = sets[key] || {};
|
||||
sets[key][this.getId()] = this;
|
||||
sets[key][this._id] = this;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -164,10 +164,10 @@ var Project = this.Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
_updateSelection: function(item) {
|
||||
if (item._selected) {
|
||||
this._selectedItemCount++;
|
||||
this._selectedItems[item.getId()] = item;
|
||||
this._selectedItems[item._id] = item;
|
||||
} else {
|
||||
this._selectedItemCount--;
|
||||
delete this._selectedItems[item.getId()];
|
||||
delete this._selectedItems[item._id];
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -327,8 +327,8 @@ var Tool = this.Tool = PaperScopeItem.extend(Callback, /** @lends Tool# */{
|
|||
var item = set[id];
|
||||
for (var key in sets) {
|
||||
var other = sets[key];
|
||||
if (other && other != set && other[item.getId()])
|
||||
delete other[item.getId()];
|
||||
if (other && other != set && other[item._id])
|
||||
delete other[item._id];
|
||||
}
|
||||
item.remove();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue