From 2488a6a1e9779f0cca4a64163ef44ac30530a450 Mon Sep 17 00:00:00 2001 From: Sebastian Speitel Date: Tue, 30 Mar 2021 11:36:46 +0200 Subject: [PATCH] perf: preinitialize typeCheck RegExp (#10990) --- src/core/util/props.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/util/props.js b/src/core/util/props.js index 26a76664ccc..f81bad37fa1 100644 --- a/src/core/util/props.js +++ b/src/core/util/props.js @@ -174,13 +174,15 @@ function assertType (value: any, type: Function): { } } +const functionTypeCheckRE = /^\s*function (\w+)/ + /** * Use function string name to check built-in types, * because a simple equality check will fail when running * across different vms / iframes. */ function getType (fn) { - const match = fn && fn.toString().match(/^\s*function (\w+)/) + const match = fn && fn.toString().match(functionTypeCheckRE) return match ? match[1] : '' }