From: Evan You Date: Fri, 15 Nov 2019 22:29:08 +0000 (-0500) Subject: perf(compiler): should only perform assertions during tests X-Git-Tag: v3.0.0-alpha.0~192 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=353b06df7756c2364b7473d0bb4e2c4c3547445e;p=thirdparty%2Fvuejs%2Fcore.git perf(compiler): should only perform assertions during tests Compiler assertions are made to ensure implementation correctness, but they have performance costs that should not affect users during development. --- diff --git a/packages/compiler-core/src/parse.ts b/packages/compiler-core/src/parse.ts index ee70ecfad3..0b0cf83fa0 100644 --- a/packages/compiler-core/src/parse.ts +++ b/packages/compiler-core/src/parse.ts @@ -141,7 +141,7 @@ function parseChildren( const nodes: TemplateChildNode[] = [] while (!isEnd(context, mode, ancestors)) { - __DEV__ && assert(context.source.length > 0) + __TEST__ && assert(context.source.length > 0) const s = context.source let node: TemplateChildNode | TemplateChildNode[] | undefined = undefined @@ -286,16 +286,16 @@ function parseCDATA( context: ParserContext, ancestors: ElementNode[] ): TemplateChildNode[] { - __DEV__ && + __TEST__ && assert(last(ancestors) == null || last(ancestors)!.ns !== Namespaces.HTML) - __DEV__ && assert(startsWith(context.source, '')) + __TEST__ && assert(startsWith(context.source, ']]>')) advanceBy(context, 3) } @@ -303,7 +303,7 @@ function parseCDATA( } function parseComment(context: ParserContext): CommentNode { - __DEV__ && assert(startsWith(context.source, '