Skip to content

Commit 2488a6a

Browse files
perf: preinitialize typeCheck RegExp (#10990)
1 parent 55a30cf commit 2488a6a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: src/core/util/props.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@ function assertType (value: any, type: Function): {
174174
}
175175
}
176176

177+
const functionTypeCheckRE = /^\s*function (\w+)/
178+
177179
/**
178180
* Use function string name to check built-in types,
179181
* because a simple equality check will fail when running
180182
* across different vms / iframes.
181183
*/
182184
function getType (fn) {
183-
const match = fn && fn.toString().match(/^\s*function (\w+)/)
185+
const match = fn && fn.toString().match(functionTypeCheckRE)
184186
return match ? match[1] : ''
185187
}
186188

0 commit comments

Comments
 (0)