perf(compiler): minor perf tweaks

This commit is contained in:
Evan You 2019-11-15 16:47:55 -05:00
parent 4fef8f342a
commit 51d57b4566
4 changed files with 4 additions and 5 deletions

View File

@ -156,7 +156,7 @@ exports[`compiler: hoistStatic transform prefixIdentifiers hoist class with stat
"const _Vue = Vue "const _Vue = Vue
const _createVNode = Vue.createVNode const _createVNode = Vue.createVNode
const _hoisted_1 = { class: { foo: true }} const _hoisted_1 = { class: { foo: true } }
return function render() { return function render() {
with (this) { with (this) {

View File

@ -552,8 +552,7 @@ function genObjectExpression(node: ObjectExpression, context: CodegenContext) {
} }
} }
multilines && deindent() multilines && deindent()
const lastChar = context.code[context.code.length - 1] push(multilines ? `}` : ` }`)
push(multilines || /[\])}]/.test(lastChar) ? `}` : ` }`)
} }
function genArrayExpression(node: ArrayExpression, context: CodegenContext) { function genArrayExpression(node: ArrayExpression, context: CodegenContext) {

View File

@ -595,7 +595,7 @@ function parseAttribute(
let arg: ExpressionNode | undefined let arg: ExpressionNode | undefined
if (match[2]) { if (match[2]) {
const startOffset = name.split(match[2], 2)!.shift()!.length const startOffset = name.indexOf(match[2])
const loc = getSelection( const loc = getSelection(
context, context,
getNewPosition(context, start, startOffset), getNewPosition(context, start, startOffset),

View File

@ -15,7 +15,7 @@ return function render() {
_createVNode(\\"div\\", { innerHTML: html }, null, 8 /* PROPS */, [\\"innerHTML\\"]), _createVNode(\\"div\\", { innerHTML: html }, null, 8 /* PROPS */, [\\"innerHTML\\"]),
_createVNode(\\"div\\", null, \\"test\\"), _createVNode(\\"div\\", null, \\"test\\"),
_createVNode(\\"div\\", { style: _hoisted_1 }, \\"red\\"), _createVNode(\\"div\\", { style: _hoisted_1 }, \\"red\\"),
_createVNode(\\"div\\", { style: {color: 'green'}}, null, 4 /* STYLE */) _createVNode(\\"div\\", { style: {color: 'green'} }, null, 4 /* STYLE */)
])) ]))
} }
}" }"