mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 21:40:38 +02:00
Further reduce number of Entites.getEntityProperties() calls
This commit is contained in:
parent
c34344161e
commit
821f5de3e3
1 changed files with 18 additions and 0 deletions
|
@ -33,7 +33,19 @@ if (typeof Uuid.SELF !== "string") {
|
|||
}
|
||||
|
||||
if (typeof Entities.rootOf !== "function") {
|
||||
Entities.rootOfCache = {
|
||||
CACHE_ENTRY_EXPIRY_TIME: 1000 // ms
|
||||
};
|
||||
|
||||
Entities.rootOf = function (entityID) {
|
||||
if (Entities.rootOfCache[entityID]) {
|
||||
if (Date.now() - Entities.rootOfCache[entityID].timeStamp
|
||||
< Entities.rootOfCache.CACHE_ENTRY_EXPIRY_TIME) {
|
||||
return Entities.rootOfCache[entityID].rootOf;
|
||||
}
|
||||
delete Entities.rootOfCache[entityID];
|
||||
}
|
||||
|
||||
var rootEntityID,
|
||||
entityProperties,
|
||||
PARENT_PROPERTIES = ["parentID"];
|
||||
|
@ -43,6 +55,11 @@ if (typeof Entities.rootOf !== "function") {
|
|||
rootEntityID = entityProperties.parentID;
|
||||
entityProperties = Entities.getEntityProperties(rootEntityID, PARENT_PROPERTIES);
|
||||
}
|
||||
|
||||
Entities.rootOfCache[entityID] = {
|
||||
rootOf: rootEntityID,
|
||||
timeStamp: Date.now()
|
||||
};
|
||||
return rootEntityID;
|
||||
};
|
||||
}
|
||||
|
@ -71,6 +88,7 @@ if (typeof Entities.hasEditableRoot !== "function") {
|
|||
properties = Entities.getEntityProperties(properties.parentID, EDITIBLE_ENTITY_QUERY_PROPERTYES);
|
||||
}
|
||||
isEditable = properties.visible && !properties.locked && NONEDITABLE_ENTITY_TYPES.indexOf(properties.type) === -1;
|
||||
|
||||
Entities.hasEditableRootCache[entityID] = {
|
||||
hasEditableRoot: isEditable,
|
||||
timeStamp: Date.now()
|
||||
|
|
Loading…
Reference in a new issue