wip: defer patchData as nodeOp

This commit is contained in:
Evan You
2018-11-12 22:07:55 -05:00
parent 2f3ddf20b5
commit 65c1ea8930
2 changed files with 49 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
// A data structure that stores a deferred DOM operation.
// the first element is the function to call, and the rest of the array
// stores up to 3 arguments.
// stores up to 8 arguments.
type Op = [Function, ...any[]]
// A "job" stands for a unit of work that needs to be performed.
@@ -375,5 +375,11 @@ function commitJob(job: Job) {
function applyOp(op: Op) {
const fn = op[0]
fn(op[1], op[2], op[3])
// optimize for more common cases
// only patchData needs 8 arguments
if (op.length <= 3) {
fn(op[1], op[2], op[3])
} else {
fn(op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8])
}
}