Skip to content

Commit 5ba9e6e

Browse files
committed
perf(Mutation): drop object spread operation in patch()
patch() method on Mutation can be heavily used during large amount of database upsert operations. Yet it is performing poorly for seemingly simple operation (updating `this.params`). The object spread seems to be the culprit. In this PR, simple "loop + assignment" is used to prevent unnecessary object creation as in the original implementation. Note: `Object.assign` is sadly not available for targeting ES5. Otherwise, it would be an even better choice.
1 parent e68d870 commit 5ba9e6e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/storage/modules/Mutation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ export class Mutation {
9999
}
100100

101101
patch(patch: Object) {
102-
this.params = { ...this.params, ...patch }
102+
forEach(patch, (val, key) => {
103+
this.params[key] = val
104+
})
103105
return this
104106
}
105107

0 commit comments

Comments
 (0)