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.
This commit is contained in:
Evan You
2019-11-15 17:29:08 -05:00
parent 51d57b4566
commit 353b06df77
4 changed files with 32 additions and 25 deletions

View File

@@ -77,7 +77,7 @@ export function getInnerRange(
offset: number,
length?: number
): SourceLocation {
__DEV__ && assert(offset <= loc.source.length)
__TEST__ && assert(offset <= loc.source.length)
const source = loc.source.substr(offset, length)
const newLoc: SourceLocation = {
source,
@@ -86,7 +86,7 @@ export function getInnerRange(
}
if (length != null) {
__DEV__ && assert(offset + length <= loc.source.length)
__TEST__ && assert(offset + length <= loc.source.length)
newLoc.end = advancePositionWithClone(
loc.start,
loc.source,