Skip to content

Commit 2db5ec5

Browse files
committedJul 13, 2021
Improve memory usage when merging options
1 parent 099bbfe commit 2db5ec5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎source/core/options.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ export default class Options {
829829

830830
init(this, options, this);
831831
init(options, options, this);
832-
this._init.push(options);
833832

834833
// This is way much faster than cloning ^_^
835834
Object.freeze(options);
@@ -846,6 +845,8 @@ export default class Options {
846845
this._merging = true;
847846

848847
try {
848+
let push = false;
849+
849850
for (const key in options) {
850851
// `got.extend()` options
851852
if (key === 'mutableDefaults' || key === 'handlers') {
@@ -863,6 +864,12 @@ export default class Options {
863864

864865
// @ts-expect-error Type 'unknown' is not assignable to type 'never'.
865866
this[key as keyof Options] = options[key as keyof Options];
867+
868+
push = true;
869+
}
870+
871+
if (push) {
872+
this._init.push(options);
866873
}
867874
} finally {
868875
this._merging = false;

0 commit comments

Comments
 (0)
Please sign in to comment.