]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
perf(runtime-core): use `makeMap` instead of `RE` (#350)
authoredison <daiwei521@126.com>
Wed, 23 Oct 2019 14:34:58 +0000 (22:34 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 23 Oct 2019 14:34:58 +0000 (10:34 -0400)
packages/runtime-core/src/componentProps.ts

index fc8120efaa89dbc0e3912ca72799a5ab32e6f982..a8146b499facb16af607889afd1078b02e3a3216 100644 (file)
@@ -11,7 +11,8 @@ import {
   isReservedProp,
   hasOwn,
   toTypeString,
-  PatchFlags
+  PatchFlags,
+  makeMap
 } from '@vue/shared'
 import { warn } from './warning'
 import { Data, ComponentInternalInstance } from './component'
@@ -315,12 +316,14 @@ function validateProp(
   }
 }
 
-const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/
+const isSimpleType = /*#__PURE__*/ makeMap(
+  'String,Number,Boolean,Function,Symbol'
+)
 
 function assertType(value: unknown, type: PropConstructor): AssertionResult {
   let valid
   const expectedType = getType(type)
-  if (simpleCheckRE.test(expectedType)) {
+  if (isSimpleType(expectedType)) {
     const t = typeof value
     valid = t === expectedType.toLowerCase()
     // for primitive wrapper objects