Skip to content

Commit 1602365

Browse files
committed
chore: limit cloning
1 parent 0af3349 commit 1602365

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/ContextParser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
786786

787787
this.applyScopedProtected(importContext, { processingMode }, defaultExpandOptions);
788788

789-
let newContext: IJsonLdContextNormalizedRaw = { ...importContext, ...context };
789+
const newContext: IJsonLdContextNormalizedRaw = Object.assign(importContext, context);
790790

791791
// Handle terms (before protection checks)
792792
this.idifyReverseTerms(newContext);
@@ -796,7 +796,11 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
796796
const keys = Object.keys(newContext);
797797
if (typeof parentContext === 'object') {
798798
// Merge different parts of the final context in order
799-
newContext = { ...parentContext, ...newContext };
799+
for (const key in parentContext) {
800+
if (!(key in newContext)) {
801+
newContext[key] = parentContext[key];
802+
}
803+
}
800804
}
801805

802806
// Parse inner contexts with minimal processing

0 commit comments

Comments
 (0)