Skip to content

Commit b7ea7c1

Browse files
committed
perf: also hoist all-static children array
1 parent 8bc50cb commit b7ea7c1

File tree

7 files changed

+275
-230
lines changed

7 files changed

+275
-230
lines changed

Diff for: packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap

+37-28
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ exports[`compiler: hoistStatic transform hoist element with static key 1`] = `
55
const { createElementVNode: _createElementVNode } = _Vue
66
77
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", { key: \\"foo\\" }, null, -1 /* HOISTED */)
8+
const _hoisted_2 = [
9+
_hoisted_1
10+
]
811
912
return function render(_ctx, _cache) {
1013
with (_ctx) {
1114
const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
1215
13-
return (_openBlock(), _createElementBlock(\\"div\\", null, [
14-
_hoisted_1
15-
]))
16+
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_2))
1617
}
1718
}"
1819
`;
@@ -25,14 +26,15 @@ const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"p\\", null, [
2526
/*#__PURE__*/_createElementVNode(\\"span\\"),
2627
/*#__PURE__*/_createElementVNode(\\"span\\")
2728
], -1 /* HOISTED */)
29+
const _hoisted_2 = [
30+
_hoisted_1
31+
]
2832
2933
return function render(_ctx, _cache) {
3034
with (_ctx) {
3135
const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
3236
33-
return (_openBlock(), _createElementBlock(\\"div\\", null, [
34-
_hoisted_1
35-
]))
37+
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_2))
3638
}
3739
}"
3840
`;
@@ -44,14 +46,15 @@ const { createElementVNode: _createElementVNode, createCommentVNode: _createComm
4446
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, [
4547
/*#__PURE__*/_createCommentVNode(\\"comment\\")
4648
], -1 /* HOISTED */)
49+
const _hoisted_2 = [
50+
_hoisted_1
51+
]
4752
4853
return function render(_ctx, _cache) {
4954
with (_ctx) {
5055
const { createCommentVNode: _createCommentVNode, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
5156
52-
return (_openBlock(), _createElementBlock(\\"div\\", null, [
53-
_hoisted_1
54-
]))
57+
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_2))
5558
}
5659
}"
5760
`;
@@ -62,15 +65,16 @@ const { createElementVNode: _createElementVNode } = _Vue
6265
6366
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */)
6467
const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"div\\", null, null, -1 /* HOISTED */)
68+
const _hoisted_3 = [
69+
_hoisted_1,
70+
_hoisted_2
71+
]
6572
6673
return function render(_ctx, _cache) {
6774
with (_ctx) {
6875
const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
6976
70-
return (_openBlock(), _createElementBlock(\\"div\\", null, [
71-
_hoisted_1,
72-
_hoisted_2
73-
]))
77+
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_3))
7478
}
7579
}"
7680
`;
@@ -80,14 +84,15 @@ exports[`compiler: hoistStatic transform hoist simple element 1`] = `
8084
const { createElementVNode: _createElementVNode } = _Vue
8185
8286
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\", -1 /* HOISTED */)
87+
const _hoisted_2 = [
88+
_hoisted_1
89+
]
8390
8491
return function render(_ctx, _cache) {
8592
with (_ctx) {
8693
const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
8794
88-
return (_openBlock(), _createElementBlock(\\"div\\", null, [
89-
_hoisted_1
90-
]))
95+
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_2))
9196
}
9297
}"
9398
`;
@@ -175,14 +180,15 @@ exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static t
175180
const { createElementVNode: _createElementVNode } = _Vue
176181
177182
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", null, \\"foo \\" + /*#__PURE__*/_toDisplayString(1) + \\" \\" + /*#__PURE__*/_toDisplayString(true), -1 /* HOISTED */)
183+
const _hoisted_2 = [
184+
_hoisted_1
185+
]
178186
179187
return function render(_ctx, _cache) {
180188
with (_ctx) {
181189
const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
182190
183-
return (_openBlock(), _createElementBlock(\\"div\\", null, [
184-
_hoisted_1
185-
]))
191+
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_2))
186192
}
187193
}"
188194
`;
@@ -192,14 +198,15 @@ exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static t
192198
const { createElementVNode: _createElementVNode } = _Vue
193199
194200
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", { foo: 0 }, /*#__PURE__*/_toDisplayString(1), -1 /* HOISTED */)
201+
const _hoisted_2 = [
202+
_hoisted_1
203+
]
195204
196205
return function render(_ctx, _cache) {
197206
with (_ctx) {
198207
const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
199208
200-
return (_openBlock(), _createElementBlock(\\"div\\", null, [
201-
_hoisted_1
202-
]))
209+
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_2))
203210
}
204211
}"
205212
`;
@@ -368,16 +375,17 @@ const { createElementVNode: _createElementVNode } = _Vue
368375
369376
const _hoisted_1 = { id: \\"foo\\" }
370377
const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */)
378+
const _hoisted_3 = [
379+
_hoisted_2
380+
]
371381
372382
return function render(_ctx, _cache) {
373383
with (_ctx) {
374384
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createElementVNode: _createElementVNode } = _Vue
375385
376386
return (_openBlock(), _createElementBlock(\\"div\\", null, [
377387
(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(list, (i) => {
378-
return (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, [
379-
_hoisted_2
380-
]))
388+
return (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, _hoisted_3))
381389
}), 256 /* UNKEYED_FRAGMENT */))
382390
]))
383391
}
@@ -393,16 +401,17 @@ const _hoisted_1 = {
393401
id: \\"foo\\"
394402
}
395403
const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */)
404+
const _hoisted_3 = [
405+
_hoisted_2
406+
]
396407
397408
return function render(_ctx, _cache) {
398409
with (_ctx) {
399410
const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
400411
401412
return (_openBlock(), _createElementBlock(\\"div\\", null, [
402413
ok
403-
? (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, [
404-
_hoisted_2
405-
]))
414+
? (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, _hoisted_3))
406415
: _createCommentVNode(\\"v-if\\", true)
407416
]))
408417
}

0 commit comments

Comments
 (0)