small attribute optimizations

This commit is contained in:
zadam
2023-01-27 08:46:04 +01:00
parent ad887c4b12
commit 2b4dfaef7f
3 changed files with 34 additions and 26 deletions

View File

@@ -126,7 +126,9 @@ class SNote extends AbstractShacaEntity {
* @returns {SAttribute[]} all note's attributes, including inherited ones
*/
getAttributes(type, name) {
this.__getAttributes([]);
if (!this.__attributeCache) {
this.__getAttributes([]);
}
if (type && name) {
return this.__attributeCache.filter(attr => attr.type === type && attr.name === name && !isCredentials(attr));
@@ -428,11 +430,6 @@ class SNote extends AbstractShacaEntity {
return this.hasAttribute('label', 'archived');
}
/** @returns {boolean} */
hasInheritableOwnedArchivedLabel() {
return !!this.ownedAttributes.find(attr => attr.type === 'label' && attr.name === 'archived' && attr.isInheritable);
}
/** @returns {boolean} */
isInherited() {
return !!this.targetRelations.find(rel => rel.name === 'template' || rel.name === 'inherit');