Skip to content

Commit f143485

Browse files
committed
perf: couple of small micro-optimizations re: #13191
1 parent a1b7bb5 commit f143485

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: lib/document.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1130,8 +1130,8 @@ Document.prototype.$set = function $set(path, val, type, options) {
11301130
}
11311131

11321132
if (utils.isNonBuiltinObject(valForKey) && pathtype === 'nested') {
1133-
this.$set(prefix + key, path[key], constructing, Object.assign({}, options, { _skipMarkModified: true }));
1134-
$applyDefaultsToNested(this.$get(prefix + key), prefix + key, this);
1133+
this.$set(pathName, path[key], constructing, Object.assign({}, options, { _skipMarkModified: true }));
1134+
$applyDefaultsToNested(this.$get(oathName), pathName, this);
11351135
continue;
11361136
} else if (strict) {
11371137
// Don't overwrite defaults with undefined keys (gh-3981) (gh-9039)
@@ -1146,9 +1146,9 @@ Document.prototype.$set = function $set(path, val, type, options) {
11461146

11471147
if (pathtype === 'real' || pathtype === 'virtual') {
11481148
const p = path[key];
1149-
this.$set(prefix + key, p, constructing, options);
1149+
this.$set(pathName, p, constructing, options);
11501150
} else if (pathtype === 'nested' && path[key] instanceof Document) {
1151-
this.$set(prefix + key,
1151+
this.$set(pathName,
11521152
path[key].toObject({ transform: false }), constructing, options);
11531153
} else if (strict === 'throw') {
11541154
if (pathtype === 'nested') {
@@ -1158,7 +1158,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
11581158
}
11591159
}
11601160
} else if (path[key] !== void 0) {
1161-
this.$set(prefix + key, path[key], constructing, options);
1161+
this.$set(pathName, path[key], constructing, options);
11621162
}
11631163
}
11641164

0 commit comments

Comments
 (0)