Просмотр исходного кода

perf(compiler): minor perf tweaks

Evan You 6 лет назад
Родитель
Сommit
51d57b4566

+ 1 - 1
packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap

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

+ 1 - 2
packages/compiler-core/src/codegen.ts

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

+ 1 - 1
packages/compiler-core/src/parse.ts

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

+ 1 - 1
packages/compiler-dom/__tests__/__snapshots__/index.spec.ts.snap

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