Skip to content

Commit

Permalink
SALTO-6991: create element ID full name only if needed
Browse files Browse the repository at this point in the history
Before this change, the string with the full name of the element ID was always created even if it was never used
Changed this to create the string the first time it is needed.
  • Loading branch information
ori-moisis committed Dec 2, 2024
1 parent 288e6e9 commit 55b57e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/adapter-api/src/comparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ const compareSpecialValuesWithCircularRefs = (
if (typeof first === 'string' && typeof second === 'string') {
return compareStringsIgnoreNewlineDifferences(first, second)
}
if (first instanceof ElemID && second instanceof ElemID) {
return first.isEqual(second)
}
return undefined
}

Expand Down
6 changes: 4 additions & 2 deletions packages/adapter-api/src/element_id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,12 @@ export class ElemID {
readonly typeName: string
readonly idType: ElemIDType
private readonly nameParts: ReadonlyArray<string>
private readonly fullName: string
private fullName?: string
constructor(adapter: string, typeName?: string, idType?: ElemIDType, ...name: ReadonlyArray<string>) {
this.adapter = adapter
this.typeName = _.isEmpty(typeName) ? ElemID.CONFIG_NAME : (typeName as string)
this.idType = idType || ElemID.getDefaultIdType(adapter)
this.nameParts = name
this.fullName = this.generateFullName()
}

get name(): string {
Expand Down Expand Up @@ -166,6 +165,9 @@ export class ElemID {
}

getFullName(): string {
if (this.fullName === undefined) {
this.fullName = this.generateFullName()
}
return this.fullName
}

Expand Down

0 comments on commit 55b57e1

Please sign in to comment.